Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using static System.Console;
- using System.Globalization;
- public class TestClassifiedAd
- {
- public static void Main()
- {
- ClassifiedAd myClassifiedAd = new ClassifiedAd();
- ClassifiedAd yourClassifiedAd = new ClassifiedAd();
- myClassifiedAd.Category = "used cars";
- myClassifiedAd.Words = 100;
- yourClassifiedAd.Category = "Help Wanted";
- yourClassifiedAd.Words = 60;
- WriteLine("The classified ad with {0} words in category {1} costs {2}", myClassifiedAd.Words, myClassifiedAd.Category, myClassifiedAd.price.ToString("C",CultureInfo.GetCultureInfo("en-US")));
- WriteLine("The classified ad with {0} words in category {1} costs {2}", yourClassifiedAd.Words, yourClassifiedAd.Category, yourClassifiedAd.price.ToString("C",CultureInfo.GetCultureInfo("en-US")));
- }
- }
- class ClassifiedAd
- {
- const double PRICE_PER_WORD = 0.09;
- public int words;
- public double price;
- public string Category {get;set;}
- public int Words
- {
- get
- {
- return words;
- }
- set
- {
- words = value;
- price = words * PRICE_PER_WORD;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement