Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.67 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package ejerciciosupermercado;
  7.  
  8. /**
  9.  *
  10.  * @author Eliseo
  11.  */
  12. public class Carne extends Producto {
  13.  
  14.     private char categoria;
  15.  
  16.     public Carne() {
  17.         super();
  18.         categoria = 'x';
  19.     }
  20.  
  21.     public Carne(String codigo, int valor, int stock, String pais, int cantidad, Dias dias, char categoria) {
  22.         super(codigo, valor, stock, pais, cantidad, dias);
  23.         setCategoria(categoria);
  24.     }
  25.  
  26.     public char getCategoria() {
  27.         return categoria;
  28.     }
  29.  
  30.     public void setCategoria(char categoria) {
  31.         switch (categoria) {
  32.             case 'V':
  33.                 this.categoria = categoria;
  34.                 break;
  35.             case 'A':
  36.                 this.categoria = categoria;
  37.                 break;
  38.             case 'C':
  39.                 this.categoria = categoria;
  40.                 break;
  41.             case 'U':
  42.                 this.categoria = categoria;
  43.                 break;
  44.             case 'N':
  45.                 this.categoria = categoria;
  46.                 break;
  47.             case 'O':
  48.                 this.categoria = categoria;
  49.                 break;
  50.             default:
  51.                 this.categoria = categoria;
  52.                 System.out.println("No entra en categoría");
  53.                 break;
  54.         }
  55.     }
  56.  
  57.     public void ImprimirStatus() {
  58.         System.out.println(this);
  59.         System.out.println("Total de los productos carne: " + total());
  60.     }
  61.  
  62.     public double total() {
  63.         double total;
  64.         if (super.getDias() == Dias.MIERCOLES) {
  65.             total = (super.getValor() * super.getCantidad()) * porcentajeDescuento();
  66.             total = (super.getValor()*super.getCantidad()) - total;
  67.             return total;
  68.         } else {
  69.             //vas a devolver el total en 0??
  70.             total = super.getValor() * super.getCantidad();
  71.             return total;
  72.         }
  73.  
  74.     }
  75.  
  76.     @Override
  77.     public String toString() {
  78.         return "Codigo: " + super.getCodigo() + "\n"
  79.                 + "Valor: " + super.getValor() + "\n"
  80.                 + "Stock: " + super.getStock() + "\n"
  81.                 + "Pais: " + super.getPais() + "\n"
  82.                 + "Categoria" + getCategoria() + "\n"
  83.                 + "Cantidad :" + super.getCantidad() + "\n"
  84.                 + "Dia: " + super.getDias() + "\n"
  85.                 + "Total: " + total();
  86.  
  87.     }
  88.  
  89.     @Override
  90.     public double porcentajeDescuento() {
  91.         double porcentajeDescuento = 0.08;
  92.         return porcentajeDescuento;
  93.     }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement