gonzalob

Untitled

Apr 17th, 2020
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. package clases_abs;
  2.  
  3. public abstract  class Libro implements Interfaz, Comparable<Libro>
  4. {
  5.     private int cantidadhojas;
  6.    
  7.     public Libro(int CantidadHojas)
  8.     {
  9.         this.cantidadhojas = CantidadHojas;
  10.     }
  11.    
  12.     public int getCantidadhojas() {
  13.         return cantidadhojas;
  14.     }
  15.    
  16.     public void setCantidadhojas(int cantidadhojas) {
  17.         this.cantidadhojas = cantidadhojas;
  18.     }
  19.    
  20.     @Override
  21.     public String toString() {
  22.         // TODO Auto-generated method stub
  23.         return "tus hojas son..."+getCantidadhojas();
  24.     }
  25.    
  26.     public void metodoComun()
  27.     {
  28.         char mander = 's';
  29.     }
  30.    
  31.     public abstract double getPrecio();
  32.  
  33.     @Override
  34.     public void algo() {
  35.         int a = 10;
  36.        
  37.     }
  38.    
  39.     @Override
  40.     public int compareTo(Libro o)
  41.     {
  42.         //si son iguales > 0
  43.         if (o.getCantidadhojas() == getCantidadhojas()) return 0;
  44.         if (getCantidadhojas() > o.getCantidadhojas()) return 1;
  45.         if (getCantidadhojas() < o.getCantidadhojas()) return -1;
  46.         return 0;
  47.        
  48.     }
  49.    
  50.     @Override
  51.     public boolean equals(Object obj)
  52.     {
  53.         Libro o = (Libro)obj;
  54.         if (o.getCantidadhojas() == getCantidadhojas()) return true;
  55.         else return false;
  56.     }
  57.    
  58.    
  59.     @Override
  60.     public int hashCode() {
  61.         // TODO Auto-generated method stub
  62.         return 0;
  63.     }
  64.    
  65.    
  66. }
Add Comment
Please, Sign In to add comment