Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package ejerciciosupermercado;
- /**
- *
- * @author Eliseo
- */
- public class Carne extends Producto {
- private char categoria;
- public Carne() {
- super();
- categoria = 'x';
- }
- public Carne(String codigo, int valor, int stock, String pais, int cantidad, Dias dias, char categoria) {
- super(codigo, valor, stock, pais, cantidad, dias);
- setCategoria(categoria);
- }
- public char getCategoria() {
- return categoria;
- }
- public void setCategoria(char categoria) {
- switch (categoria) {
- case 'V':
- this.categoria = categoria;
- break;
- case 'A':
- this.categoria = categoria;
- break;
- case 'C':
- this.categoria = categoria;
- break;
- case 'U':
- this.categoria = categoria;
- break;
- case 'N':
- this.categoria = categoria;
- break;
- case 'O':
- this.categoria = categoria;
- break;
- default:
- this.categoria = categoria;
- System.out.println("No entra en categoría");
- break;
- }
- }
- public void ImprimirStatus() {
- System.out.println(this);
- System.out.println("Total de los productos carne: " + total());
- }
- public double total() {
- double total;
- if (super.getDias() == Dias.MIERCOLES) {
- total = (super.getValor() * super.getCantidad()) * porcentajeDescuento();
- total = (super.getValor()*super.getCantidad()) - total;
- return total;
- } else {
- //vas a devolver el total en 0??
- total = super.getValor() * super.getCantidad();
- return total;
- }
- }
- @Override
- public String toString() {
- return "Codigo: " + super.getCodigo() + "\n"
- + "Valor: " + super.getValor() + "\n"
- + "Stock: " + super.getStock() + "\n"
- + "Pais: " + super.getPais() + "\n"
- + "Categoria" + getCategoria() + "\n"
- + "Cantidad :" + super.getCantidad() + "\n"
- + "Dia: " + super.getDias() + "\n"
- + "Total: " + total();
- }
- @Override
- public double porcentajeDescuento() {
- double porcentajeDescuento = 0.08;
- return porcentajeDescuento;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement