Esempio n. 1
0
        public void GlovesBowDecoratorTest()
        {
            VehicleDecorator planeDecorator = new GlovesDecorator(new Plane());

            planeDecorator = new BowDecorator(planeDecorator);

            Assert.AreEqual(2, planeDecorator.GetDef());
            Assert.AreEqual(8, planeDecorator.GetAtt());
        }
Esempio n. 2
0
        public static void DecoratorUsage()
        {
            VehicleDecorator carDecorator = new ShieldDecorator(new Car());

            System.Console.WriteLine($"Att: {carDecorator.GetAtt()}, Def: {carDecorator.GetDef()}");
            carDecorator = new SwordDecorator(carDecorator);
            System.Console.WriteLine($"Att: {carDecorator.GetAtt()}, Def: {carDecorator.GetDef()}");
            carDecorator = new ArmorDecorator(carDecorator);
            carDecorator = new BowDecorator(carDecorator);
            System.Console.WriteLine($"Att: {carDecorator.GetAtt()}, Def: {carDecorator.GetDef()}");
        }