Advertisement
desislava_topuzakova

Untitled

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