Advertisement
POdkovyrkinDaniil

Untitled

Dec 8th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 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 HotelAccounting
  8. {
  9.     class AccountingModel : ModelBase
  10.     {
  11.         //double Price(должно быть не меньше 0)
  12.         //int NightsCount(должно быть больше 0)
  13.         //double Discount(скидка.Ограничений нет)
  14.         //double Total(должно быть больше нуля
  15.         private double price;
  16.         private int nightsCount;
  17.         private double discount;
  18.         private double total;
  19.         public double Price
  20.         {
  21.             get => price;
  22.             set
  23.             {
  24.                 if (value < 0)
  25.                     throw new ArgumentException();
  26.                 price = value;
  27.                 Total = Price * NightsCount * (1 - Discount / 100);
  28.                 Notify(nameof(Price));
  29.                 Notify(nameof(Total));
  30.                
  31.             }
  32.         }
  33.         public int NightsCount
  34.         {
  35.             get => nightsCount;
  36.             set
  37.             {
  38.                 if (value <= 0)
  39.                         throw new ArgumentException();
  40.                 nightsCount = value;
  41.                 Total = Price * NightsCount * (1 - Discount / 100);
  42.                 Notify(nameof(NightsCount));
  43.                 Notify(nameof(Total));
  44.             }
  45.         }
  46.         public double Discount
  47.         {
  48.             get => discount;
  49.             set
  50.             {
  51.                 discount = value;
  52.                 Total = Price * NightsCount * (1 - Discount / 100);
  53.                 Notify(nameof(Total));
  54.                 Notify(nameof(Discount));
  55.                    
  56.                
  57.             }
  58.         }
  59.         public double Total
  60.         {
  61.             get => total;
  62.             set
  63.             {
  64.                 if (value <= 0)
  65.                     throw new ArgumentException();
  66.                 total = value;
  67.                 discount = 100 * (1 - total / (Price * NightsCount));
  68.                 Notify(nameof(Discount));
  69.                 Notify(nameof(Total));
  70.                
  71.             }
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement