示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
        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();
        }
示例#4
0
        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();
        }
示例#5
0
 public BaseCar BeNice(BaseCar car)
 {
     Console.WriteLine("be nice");
     car.beNice = true;
     return(car);
 }
示例#6
0
 public BaseCar SteadUp(BaseCar car)
 {
     Console.WriteLine("stead up");
     car.steadUp = true;
     return(car);
 }
示例#7
0
 public BaseCar SpeedUp(BaseCar car)
 {
     Console.WriteLine("speed up");
     car.speedUp = true;
     return(car);
 }