Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.09 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.         private double price;
  12.         private int nightsCount;
  13.         private double discount;
  14.         private double total;
  15.  
  16.         public double Price
  17.         {
  18.             get
  19.             {
  20.                 return price;
  21.             }
  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.  
  33.         public int NightsCount
  34.         {
  35.             get
  36.             {
  37.                 return nightsCount;
  38.             }
  39.             set
  40.             {
  41.  
  42.                 if (value <= 0)
  43.                     throw new ArgumentException();
  44.                 nightsCount = value;
  45.                 total = price * nightsCount * (1 - discount / 100);
  46.                 Notify(nameof(NightsCount));
  47.                 Notify(nameof(Total));
  48.  
  49.             }
  50.         }
  51.         public double Discount
  52.         {
  53.             get
  54.             {
  55.                 return discount;
  56.             }
  57.             set
  58.             {
  59.                 if (value > 100)
  60.                     throw new ArgumentException();
  61.                 discount = value;
  62.                 total = price * nightsCount * (1 - discount / 100);
  63.                 Notify(nameof(Discount));
  64.                 Notify(nameof(Total));
  65.             }
  66.         }
  67.  
  68.         public double Total
  69.         {
  70.             get
  71.             {
  72.                 return total;
  73.             }
  74.             set
  75.             {
  76.                 if (value < 0)
  77.                     throw new ArgumentException();
  78.                 total = value;
  79.                 discount = 100 - (total * 100 / (price * nightsCount));
  80.                 Notify(nameof(Discount));
  81.                 Notify(nameof(Total));
  82.             }
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement