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
- {
- class AccountingModel : ModelBase
- {
- //double Price(должно быть не меньше 0)
- //int NightsCount(должно быть больше 0)
- //double Discount(скидка.Ограничений нет)
- //double Total(должно быть больше нуля
- private double price;
- private int nightsCount;
- private double discount;
- private double total;
- public double Price
- {
- get => price;
- set
- {
- if (value < 0)
- throw new ArgumentException();
- price = value;
- Total = Price * NightsCount * (1 - Discount / 100);
- Notify(nameof(Price));
- Notify(nameof(Total));
- }
- }
- public int NightsCount
- {
- get => nightsCount;
- set
- {
- if (value <= 0)
- throw new ArgumentException();
- nightsCount = value;
- Total = Price * NightsCount * (1 - Discount / 100);
- Notify(nameof(NightsCount));
- Notify(nameof(Total));
- }
- }
- public double Discount
- {
- get => discount;
- set
- {
- discount = value;
- Total = Price * NightsCount * (1 - Discount / 100);
- Notify(nameof(Total));
- Notify(nameof(Discount));
- }
- }
- public double Total
- {
- get => total;
- set
- {
- if (value <= 0)
- throw new ArgumentException();
- total = value;
- discount = 100 * (1 - total / (Price * NightsCount));
- Notify(nameof(Discount));
- Notify(nameof(Total));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement