Advertisement
POdkovyrkinDaniil

Untitled

Dec 8th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 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. 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. Notify(nameof(Total));
  31.  
  32. }
  33. }
  34.  
  35. public int NightsCount
  36. {
  37. get => nightsCount;
  38. set
  39. {
  40. if (value <= 0)
  41. throw new ArgumentException();
  42. nightsCount = value;
  43. Notify(nameof(NightsCount));
  44. Total = Price * NightsCount * (1 - Discount / 100);
  45. Notify(nameof(Total));
  46. }
  47. }
  48.  
  49. public double Discount
  50. {
  51. get => discount;
  52. set
  53. {
  54. if (value >= 100)
  55. throw new ArgumentException();
  56. discount = value;
  57. Notify(nameof(Discount));
  58. Total = Price * NightsCount * (1 - Discount / 100);
  59. Notify(nameof(Total));
  60. }
  61. }
  62.  
  63. public double Total
  64. {
  65. get => total;
  66. set
  67. {
  68. if (value <= 0)
  69. throw new ArgumentException();
  70. total = value;
  71. Notify(nameof(Total));
  72. discount = 100 * (1 - Total / (Price * NightsCount));
  73. Notify(nameof(Discount));
  74. }
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement