public void ShieldSwordDecoratorTest() { VehicleDecorator carDecorator = new ShieldDecorator(new Car()); carDecorator = new SwordDecorator(carDecorator); Assert.AreEqual(8, carDecorator.GetDef()); Assert.AreEqual(8, carDecorator.GetAtt()); }
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()}"); }