Advertisement
Guest User

Upgrade }{Y|TA

a guest
Dec 6th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml;
  8.  
  9. namespace HotelAccounting
  10. {
  11.     //создайте класс AccountingModel здесь
  12.     public class AccountingModel : ModelBase
  13.     {
  14.         private double price;
  15.  
  16.         public double Price
  17.         {
  18.             get { return price; }
  19.             set
  20.             {
  21.                 if (value < 0) throw new ArgumentException();
  22.                 else
  23.                 {
  24.                     price = value;
  25.                     Notify(nameof(Price));
  26.                     Notify(nameof(Total));
  27.                 }
  28.             }
  29.         }
  30.  
  31.         private int nightsCount;
  32.  
  33.         public int NightsCount
  34.         {
  35.             get { return nightsCount; }
  36.             set
  37.             {
  38.                 if (value <= 0) throw new ArgumentException();
  39.                 else
  40.                 {
  41.                     nightsCount = value;
  42.                     Notify(nameof(NightsCount));
  43.                     Notify(nameof(Total));
  44.                 }
  45.             }
  46.         }
  47.  
  48.         private double discount;
  49.  
  50.         public double Discount
  51.         {
  52.             get
  53.             {
  54.                 return discount;
  55.             }
  56.             set
  57.             {
  58.                 if (value > 100) throw new ArgumentException();
  59.                 discount = value;
  60.                 Notify(nameof(Discount));
  61.                 Notify(nameof(Total));
  62.             }
  63.         }
  64.  
  65.         private double total;
  66.  
  67.         public double Total
  68.         {
  69.             get { return Price*NightsCount*(1 - Discount/100); }
  70.             set
  71.             {
  72.                 if (value <= 0) throw new ArgumentException();
  73.                 Discount = 100 - 100*value/(Price*NightsCount);
  74.             }
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement