Advertisement
desislava_topuzakova

Untitled

May 21st, 2023
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace RegularExam
  6. {
  7. internal class Perfume
  8. {
  9. private string brand;
  10. private double price;
  11.  
  12. public Perfume (string brand, double price)
  13. {
  14. Brand = brand;
  15. Price = price;
  16. }
  17.  
  18. public string Brand
  19. {
  20. get { return brand; }
  21. set { brand = value; }
  22. }
  23. public double Price
  24. {
  25. get { return price; }
  26. set
  27. {
  28. if (value > 100)
  29. {
  30. throw new ArgumentException("Invalid perfume price!");
  31. }
  32. price = value;
  33. }
  34. }
  35.  
  36. public override string ToString()
  37. {
  38. return $"Perfume {brand} costs {price:F2}";
  39. }
  40. }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement