예제 #1
0
        public void ShieldSwordDecoratorTest()
        {
            VehicleDecorator carDecorator = new ShieldDecorator(new Car());

            carDecorator = new SwordDecorator(carDecorator);

            Assert.AreEqual(8, carDecorator.GetDef());
            Assert.AreEqual(8, carDecorator.GetAtt());
        }
예제 #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()}");
        }