Advertisement
desislava_topuzakova

Flower.cs

May 15th, 2022
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.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 RegularExam
  8. {
  9. internal class Flower
  10. {
  11. private string type;
  12. private string color;
  13. private double price;
  14.  
  15. public Flower(string type, string color, double price)
  16. {
  17. Type = type;
  18. Color = color;
  19. Price = price;
  20. }
  21.  
  22. public string Type
  23. {
  24. get { return type; }
  25. set { type = value;}
  26. }
  27. public string Color
  28. {
  29. get { return color; }
  30. set { color = value; }
  31. }
  32. public double Price
  33. {
  34. get { return price; }
  35. set
  36. {
  37. if (value > 100)
  38. {
  39. throw new ArgumentException("Invalid flower price!");
  40. }
  41. price = value;
  42. }
  43. }
  44.  
  45. public override string ToString()
  46. {
  47. return $"Flower {type} with color {color} costs {price:F2}";
  48. }
  49. }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement