Metziop

Receta

Apr 28th, 2022
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 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 SimiUnadm
  8. {
  9.     public class RecetaMedica
  10.     {
  11.         private string medicamentoAsurtir;
  12.         private int cantidad;
  13.         private string forma;
  14.         private double dosis;
  15.         private DateTime fechaInicial;
  16.         private DateTime fechaFinal;
  17.         private double precio;
  18.  
  19.  
  20.  
  21.  
  22.  
  23.         //contructor
  24.         public RecetaMedica() //se inicializan las variables en 0
  25.         {
  26.             this.MedicamentoAsurtir = "";
  27.             this.Forma = "";
  28.             this.Cantidad = 0;
  29.             this.Dosis = 0.0;
  30.             this.Precio = 0.0;
  31.  
  32.         }
  33.  
  34.         ~RecetaMedica() //destructor o finalizador
  35.         {
  36.             this.MedicamentoAsurtir = "";
  37.             this.Forma = "";
  38.             this.Cantidad = 0;
  39.             this.Dosis = 0.0;
  40.             this.Precio = 0.0;
  41.  
  42.         }
  43.  
  44.         public string MedicamentoAsurtir { get => medicamentoAsurtir; set => medicamentoAsurtir = value; }
  45.         public int Cantidad { get => cantidad; set => cantidad = value; }
  46.         public string Forma { get => forma; set => forma = value; }
  47.         public double Dosis { get => dosis; set => dosis = value; }
  48.         public DateTime FechaInicial { get => fechaInicial; set => fechaInicial = value; }
  49.         public DateTime FechaFinal { get => fechaFinal; set => fechaFinal = value; }
  50.         public double Precio { get => precio; set => precio = value; }
  51.  
  52.         //métodos
  53.  
  54.         public double obtenerMontoReceta()
  55.         {
  56.             if (this.Cantidad < 0)
  57.             {
  58.                 this.Cantidad = 0;
  59.             }
  60.             if (this.Precio < 0)
  61.             {
  62.                 this.Precio = 0.0;
  63.             }
  64.  
  65.             double monto = this.Cantidad * this.Precio;
  66.             return monto;
  67.         }
  68.     }
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment