Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. using static System.Console;
  2. using System.Globalization;
  3. public class TestClassifiedAd
  4. {
  5. public static void Main()
  6. {
  7. ClassifiedAd myClassifiedAd = new ClassifiedAd();
  8. ClassifiedAd yourClassifiedAd = new ClassifiedAd();
  9. myClassifiedAd.Category = "used cars";
  10. myClassifiedAd.Words = 100;
  11. yourClassifiedAd.Category = "Help Wanted";
  12. yourClassifiedAd.Words = 60;
  13. WriteLine("The classified ad with {0} words in category {1} costs {2}", myClassifiedAd.Words, myClassifiedAd.Category, myClassifiedAd.price.ToString("C",CultureInfo.GetCultureInfo("en-US")));
  14.  
  15. WriteLine("The classified ad with {0} words in category {1} costs {2}", yourClassifiedAd.Words, yourClassifiedAd.Category, yourClassifiedAd.price.ToString("C",CultureInfo.GetCultureInfo("en-US")));
  16. }
  17. }
  18. class ClassifiedAd
  19. {
  20. const double PRICE_PER_WORD = 0.09;
  21. public int words;
  22. public double price;
  23. public string Category {get;set;}
  24. public int Words
  25. {
  26. get
  27. {
  28. return words;
  29. }
  30. set
  31. {
  32. words = value;
  33. price = words * PRICE_PER_WORD;
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement