Advertisement
Jurado001

TP4ej3_Product

Oct 16th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. public class Product {
  2.     private int Codigo;
  3.     private String Descripcion;
  4.     private DateTime FechaExpiracion;
  5.     private float PrecioVenta;
  6.    
  7.     public Product() {
  8.         this.Codigo = 0;
  9.         this.Descripcion = null;
  10.         this.FechaExpiracion = null;
  11.         this.PrecioVenta = 0;
  12.     }
  13.  
  14.     public Product(int Codigo, String Descripcion, int dia, int mes, int año, float PrecioVenta) {
  15.         this.Codigo = Codigo;
  16.         this.Descripcion = Descripcion;
  17.         this.FechaExpiracion = new DateTime(dia,mes,año);
  18.         this.PrecioVenta = PrecioVenta;
  19.     }
  20.    
  21.     public int getCodigo() {
  22.         return this.Codigo;
  23.     }
  24.    
  25.     public String toString() {
  26.         return "Codigo: "+Codigo+"\nDescripcion: "+Descripcion+"\nFecha de Expiracion: "+FechaExpiracion+"\nPrecio de venta: $"+PrecioVenta+"\n";
  27.     }
  28.    
  29.     public class DateTime {
  30.         private int dia,mes,año;
  31.        
  32.         public DateTime() {
  33.             this.dia = 0;
  34.             this.mes = 0;
  35.             this.año = 0;
  36.         }
  37.        
  38.         public DateTime(int dia, int mes, int año) {
  39.             this.dia = dia;
  40.             this.mes = mes;
  41.             this.año = año;
  42.         }
  43.        
  44.         public String toString() {
  45.             return dia+"/"+mes+"/"+año;
  46.         }
  47.     }
  48.    
  49.     @Override
  50.     public boolean equals(Object item) {
  51.         int codigo = (int)item;
  52.         if(this.Codigo == codigo)
  53.             return true;
  54.         return false;      
  55.     }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement