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