Advertisement
POdkovyrkinDaniil

Untitled

Dec 8th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 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. //double Price(должно быть не меньше 0)
  12. //int NightsCount(должно быть больше 0)
  13. //double Discount(скидка.Ограничений нет)
  14. //double Total(должно быть больше нуля
  15. private double price;
  16. private int nightsCount;
  17. private double discount;
  18. private double total;
  19.  
  20. public double Price
  21. {
  22. get => price;
  23. set
  24. {
  25. if (value < 0)
  26. throw new ArgumentException();
  27. price = value;
  28. Notify(nameof(Price));
  29. Total = Price * NightsCount * (1 - Discount / 100);
  30.  
  31. }
  32. }
  33.  
  34. public int NightsCount
  35. {
  36. get => nightsCount;
  37. set
  38. {
  39. if (value <= 0)
  40. throw new ArgumentException();
  41. nightsCount = value;
  42. Notify(nameof(NightsCount));
  43. Total = Price * NightsCount * (1 - Discount / 100);
  44.  
  45. }
  46. }
  47.  
  48. public double Discount
  49. {
  50. get => discount;
  51. set
  52. {
  53. if (Math.Abs(discount - value) >= 1e-5)
  54. {
  55. discount = value;
  56. Notify(nameof(Discount));
  57. Total = Price * NightsCount * (1 - Discount / 100);
  58. }
  59.  
  60. }
  61. }
  62.  
  63. public double Total
  64. {
  65. get => total;
  66. set
  67. {
  68. if (Math.Abs(total - value) >= 1e-5)
  69. {
  70. if (value <= 0)
  71. throw new ArgumentException();
  72. total = value;
  73. Notify(nameof(Total));
  74. Discount = 100 * (1 - Total / (Price * NightsCount));
  75. }
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement