Advertisement
Guest User

"Rogues", Sсhiller

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