Advertisement
POdkovyrkinDaniil

Untitled

Dec 8th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 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(Total));
  29.                 Notify(nameof(Price));
  30.             }
  31.         }
  32.         public int NightsCount
  33.         {
  34.             get => nightsCount;
  35.             set
  36.             {
  37.                 if (value <= 0)
  38.                         throw new ArgumentException();
  39.                 nightsCount = value;
  40.                 Total = Price * NightsCount * (1 - Discount / 100);
  41.                 Notify(nameof(NightsCount));
  42.                 Notify(nameof(Total));
  43.             }
  44.         }
  45.         public double Discount
  46.         {
  47.             get => discount;
  48.             set
  49.             {
  50.                 discount = value;
  51.                 Total = Price * NightsCount * (1 - Discount / 100);
  52.                 Notify(nameof(Total));
  53.                 Notify(nameof(Discount));
  54.                    
  55.                
  56.             }
  57.         }
  58.         public double Total
  59.         {
  60.             get => total;
  61.             set
  62.             {
  63.                 if (value <= 0)
  64.                     throw new ArgumentException();
  65.                 total = value;
  66.                 discount = 100 * (1 - total / (Price * NightsCount));
  67.                 Notify(nameof(Total));
  68.                 Notify(nameof(Discount));
  69.             }
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement