Advertisement
danpalol

PolizzaBase

Nov 2nd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. public class PolizzaBase implements Cloneable{
  2.    
  3.     private int value;
  4.     private String targ;
  5.    
  6.     public PolizzaBase(String targa,int valore){
  7.         targ=targa;
  8.         value=valore;
  9.        
  10.     }
  11.    
  12.     public String getTarga(){
  13.         return targ;
  14.     }
  15.    
  16.     public int getValoreRC(){
  17.         return value;
  18.     }
  19.    
  20.     public int getPremioAnnuo(){
  21.         return value/100;
  22.     }
  23.     public String toString(){
  24.         return "Targa="+targ+"ValoreRC="+value;
  25.     }
  26.     public Object clone(){
  27.         try{
  28.             return super.clone();
  29.         }
  30.         catch(CloneNotSupportedException e){
  31.             return null;
  32.         }
  33.     }
  34.    
  35.     public boolean equals(Object otherObject){
  36.         if(otherObject==null) return false;
  37.         if(getClass() != otherObject.getClass()) return false;
  38.         PolizzaBase p = (PolizzaBase)otherObject;
  39.         return targ.equals(p.targ) && value==p.value;
  40.         }
  41.        
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement