Advertisement
Guest User

FuckHotel

a guest
Dec 15th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.83 KB | None | 0 0
  1. using System;
  2.  
  3. namespace HotelAccounting
  4. {
  5.     public class AccountingModel : ModelBase
  6.     {
  7.         private int nightsCount;
  8.         private double price;
  9.         private double discount;
  10.         private double total;
  11.         public int NightsCount
  12.         {
  13.             get { return nightsCount; }
  14.             set
  15.             {
  16.                 if (value <= 0)
  17.                     throw new ArgumentException();              
  18.                 nightsCount = value;
  19.                 Notify(nameof(NightsCount));
  20.                 Notify(nameof(Total));
  21.             }
  22.         }
  23.  
  24.         public double Price
  25.         {
  26.             get { return price; }
  27.             set
  28.             {
  29.                 if (value < 0)                
  30.                     throw new ArgumentException();                
  31.                 price = value;
  32.                 Notify(nameof(Price));
  33.                 Notify(nameof(Total));
  34.             }
  35.         }
  36.  
  37.         public double Discount
  38.         {
  39.             get { return discount; }
  40.             set
  41.             {  
  42.                 total = price * nightsCount * (1 - value / 100);
  43.                 if (total < 0)
  44.                      throw new ArgumentException();  
  45.                 discount = value;
  46.                 Notify(nameof(Discount));
  47.                 Notify(nameof(Total));
  48.             }
  49.         }
  50.  
  51.         public double Total
  52.         {
  53.             get { return price * nightsCount * (1 - discount / 100); }
  54.             set
  55.             {
  56.                 if (value < 0)                
  57.                     throw new ArgumentException();                
  58.                 else
  59.                     total = value;
  60.                 Notify(nameof(Total));
  61.                 discount = 100 * (1-(total/(price*nightsCount)));
  62.                 Notify(nameof(Discount));
  63.             }
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement