static void Main(string[] args) { ICar car = new SUV(); car = new AlloywheelsDecorator(car); car = new LeatherworkDecorator(car); car = new SunroofDecorator(car); Console.WriteLine($"Price : {car.GetPrice()}"); Console.ReadLine(); }
internal void Test() { Console.WriteLine($"\nExecution of {GetType().Name} \n"); ICar compactCar = new CompactCar(); compactCar = new NavigationDecorator(compactCar); compactCar = new SunroofDecorator(compactCar); compactCar = new LeatherSeatsDecorator(compactCar); Console.WriteLine(compactCar.Description); Console.WriteLine($"{compactCar.Price.ToString("C2")}"); // -------------------- OR -------------------- //var compactCar2 = new LeatherSeatsDecorator(new SunroofDecorator(new NavigationDecorator(new CompactCar()))); //Console.WriteLine(compactCar2.Description); //Console.WriteLine($"{compactCar.Price.ToString("C2")}"); }