static void Main(string[] args) { Car theCar = new CompactCar(); theCar = new Sunroof(theCar); Console.WriteLine(theCar.GetDescription()); Console.WriteLine(theCar.GetPrice()); }
public static void Main(string[] args) { Car theCar = new CompactCar(); theCar = new Navigation(theCar); theCar = new Sunroof(theCar); theCar = new LeatherSeats(theCar); Console.WriteLine(theCar.GetDescription()); Console.WriteLine($"{theCar.GetCarPrice():C2}"); }
public static void Main() { Car compactCar = new CompactCar(); compactCar = new Navigation(compactCar); compactCar = new Sunroof(compactCar); compactCar = new LeatherSeats(compactCar); Console.WriteLine(compactCar.GetDescription()); Console.WriteLine($"{compactCar.GetCarPrice():C2}"); }
static void Main(string[] args) { Car compactCar = new CompactCar(); compactCar = new Navigation(compactCar); compactCar = new Sunroof(compactCar); Console.WriteLine(compactCar.GetDescription()); Console.WriteLine(compactCar.GetPrice()); Console.ReadLine(); }
static void Main(string[] args) { Car theCar = new CompactCar(); //10,000 theCar = new Navigation(theCar); //5,000 theCar = new Sunroof(theCar); //2,500 theCar = new LeatherSeats(theCar); //2,500 //if you comment out each of Nav/Sun/Leather, //you'll see the total price change accordingly. //each new decorator/wrapper will add to what was already there. //ie, the price, plus whatever the extra cost is. Console.WriteLine(theCar.GetDescription()); Console.WriteLine($"{theCar.GetCarPrice():C2}"); //20,000 Console.ReadKey(); }