Advertisement
mrevilca31

Clase Lavarropa

Oct 15th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TrabajoFinal
  8. {
  9.     public class Lavarropa : Electrodomestico
  10.     {
  11.         private float cargaEnKilogramos;
  12.  
  13.         public Lavarropa():base()
  14.         {
  15.             this.cargaEnKilogramos = 10;
  16.         }
  17.  
  18.  
  19.         public Lavarropa(float precio, string color, char consumo, float peso, float cargaKG): base(precio, color, consumo, peso)
  20.         {
  21.            
  22.         }
  23.  
  24.  
  25.         private float validarCarga(float valor)
  26.         {
  27.             if (valor<0)
  28.             {
  29.                 return 10;
  30.             }
  31.             else
  32.             {
  33.                 return valor;
  34.             }
  35.         }
  36.  
  37.  
  38.         public float CargaEnKilogramos
  39.         {
  40.             get { return this.cargaEnKilogramos; }
  41.             set { this.cargaEnKilogramos = validarCarga(value); }
  42.         }
  43.  
  44.  
  45.  
  46.         private float precioCarga()
  47.         {
  48.             if (this.cargaEnKilogramos >= 10)
  49.             {
  50.                 return this.cargaEnKilogramos / 3;
  51.             }
  52.             else
  53.             {
  54.                 return 0;
  55.             }
  56.         }
  57.  
  58.  
  59.         public float PrecioFinalLavarropa
  60.         {
  61.             get { return this.PrecioFinal + precioCarga(); }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement