Advertisement
fmbalvarez

Guía 5 - Ejercicio 8 - Ticket

Sep 28th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1.  
  2. class Ticket {
  3.    
  4.     private double importe = 0;
  5.     private int ticketCerrado = 0;
  6.     private int cantidad;
  7.    
  8.     /*
  9.      * ticketCerrado. 0 equivale a false, 1 equivale a true.
  10.      *
  11.      */
  12.    
  13.     public void agregarItem(int cantidad, double precioUnitario){
  14.        
  15.         this.cantidad = cantidad;
  16.        
  17.         if (cantidad > 0 && precioUnitario > 0 && ticketCerrado == 0){
  18.            
  19.             importe = (cantidad*precioUnitario);
  20.            
  21.         }
  22.     }
  23.    
  24.     public void aplicarDescuento(double porcentaje){
  25.        
  26.         importe = importe - ((importe*porcentaje)/100);
  27.        
  28.     }
  29.    
  30.     public double calcularSubtotal(){
  31.        
  32.         return(importe);
  33.        
  34.     }
  35.    
  36.     public double calcularTotal(){
  37.        
  38.         ticketCerrado = 1;
  39.        
  40.         return(cantidad);
  41.        
  42.     }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement