Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- namespace HotelAccounting
- {
- //создайте класс AccountingModel здесь
- public class AccountingModel : ModelBase
- {
- private double price;
- public double Price
- {
- get { return price; }
- set
- {
- if (value < 0) throw new ArgumentException();
- else
- {
- price = value;
- Notify(nameof(Price));
- Notify(nameof(Total));
- }
- }
- }
- private int nightsCount;
- public int NightsCount
- {
- get { return nightsCount; }
- set
- {
- if (value <= 0) throw new ArgumentException();
- else
- {
- nightsCount = value;
- Notify(nameof(NightsCount));
- Notify(nameof(Total));
- }
- }
- }
- private double discount;
- public double Discount
- {
- get
- {
- return discount;
- }
- set
- {
- if (value > 100) throw new ArgumentException();
- discount = value;
- Notify(nameof(Discount));
- Notify(nameof(Total));
- }
- }
- private double total;
- public double Total
- {
- get { return Price*NightsCount*(1 - Discount/100); }
- set
- {
- if (value <= 0) throw new ArgumentException();
- Discount = 100 - 100*value/(Price*NightsCount);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement