private static void DoMallardDuckNewState(IDuck duck) { Console.WriteLine("Dynamically set behavior to a object. Looks like model duck will fly at the end."); duck.SetFlyBehavior(new FlyRockedPowered()); Console.Write($"{duck.GetType().Name} : "); duck.PerformFly(); }
private static void DoState(IDuck duck) { duck.Display(); duck.PerformQuack(); duck.PerformFly(); duck.Swim(); }
private static void DoIronManDuckNewState(IDuck duck) { Console.WriteLine("At the end, the rocket jet pack on the back of the IRONDUCK starts up.."); duck.SetFlyBehavior(new FlyRockedPowered()); Console.Write($"{duck.GetType().Name} : "); duck.PerformFly("Гааа-аа--аа--ззз-зз....."); }