static void Main(string[] args) { ConcreteComponent concreteComponent = new ConcreteComponent(); concreteComponent.Operation(); ConcreteDecoratorA decoratorA = new ConcreteDecoratorA(); decoratorA.SetComponent(concreteComponent); ConcreteDecoratorB decoratorB = new ConcreteDecoratorB(); decoratorB.SetComponent(concreteComponent); decoratorA.Operation(); decoratorB.Operation(); Console.WriteLine("-----------------------------"); Repo repo = new Repo(); repo.GetId(); DecoratorForIRepo decoratorForIRepo = new DecoratorForIRepo(repo); decoratorForIRepo.GetId(); Console.WriteLine("-----------------------------"); new CofeeHelper().ShouldSupportCondiments(); Console.WriteLine("-----------------------------"); BaseCar baseCar = new BaseCar(); Console.WriteLine(baseCar.GetCarCharacteristic()); Console.WriteLine(baseCar.GetCost()); ICarSet superCar = new AutomaticTransmissionSet(baseCar); Console.WriteLine(superCar.GetCarCharacteristic()); Console.WriteLine(superCar.GetCost()); }
static void Main(string[] args) { ICar baseCar = new BaseCar(); // Show how specific features of car are showCarStats(baseCar); // decorate baseCar with RaceCar and see how car chages ICar raceCar = new RaceCar(baseCar); showCarStats(raceCar); // decorate our car yet again, this time with RustyCar and see changes ICar yetSomeOtherCar = new RustyCar(raceCar); showCarStats(yetSomeOtherCar); // to show flexibility we decorate our first made car with RustyCar to show different 'decorations' work independently ICar baseRustyCar = new RustyCar(baseCar); showCarStats(baseRustyCar); }
public static void Main(string[] args) { ICar car = new BaseCar(); car = new AttackCarDecorator(car); car = new AttackCarDecorator(car); car = new AttackCarDecorator(car); car = new AttackCarDecorator(car); car = new RaceCarDecorator(car); car = new RaceCarDecorator(car); car = new ArmorCarDecorator(car); car = new ArmorCarDecorator(car); car = new ArmorCarDecorator(car); car = new ArmorCarDecorator(car); Console.WriteLine($"Car armor {car.Armor()}"); Console.WriteLine($"Car speed {car.Drive()}"); Console.WriteLine($"Car armor {car.Attack()}"); Console.ReadLine(); }
public static void Main(string[] args) { /// Creating a car var basicCar = new BaseCar("BMW", 85000); basicCar.DisplayInfo(); LineSeparator(); /// Adding one option var upgradedCar = new LeatherInteriorDecorator(1300m, basicCar); Console.WriteLine("Upgraded Car Includes:"); upgradedCar.DisplayInfo(); LineSeparator(); /// Adding all options var superCar = new V8EngineDecorator(3500m, new NavigationSystemDecorator(300m, upgradedCar)); Console.WriteLine("Super Car Includes:"); superCar.DisplayInfo(); superCar.DriveOnTrack(); LineSeparator(); }
public BaseCar BeNice(BaseCar car) { Console.WriteLine("be nice"); car.beNice = true; return(car); }
public BaseCar SteadUp(BaseCar car) { Console.WriteLine("stead up"); car.steadUp = true; return(car); }
public BaseCar SpeedUp(BaseCar car) { Console.WriteLine("speed up"); car.speedUp = true; return(car); }