public void TestModelDuck() { HeadFirstDesignPatterns.Strategy.Duck.Duck ModelDuck = new ModelDuck(); Assert.AreEqual("Quack", ModelDuck.PerformQuack()); Assert.AreEqual("I can't fly.", ModelDuck.PerformFly()); ModelDuck.FlyBehavoir = new FlyRocketPowered(); Assert.AreEqual("I'm flying with a rocket!", ModelDuck.FlyBehavoir.Fly()); Assert.AreEqual("I'm flying with a rocket!", ModelDuck.PerformFly()); ModelDuck.QuackBehavior = new MuteQuack(); Assert.AreEqual("<<silence>>", ModelDuck.QuackBehavior.Quacking()); Assert.AreEqual("<<silence>>", ModelDuck.PerformQuack()); }
static void Main(string[] args) { Console.WriteLine("Game"); Character character = new King(); character.SetWeapon(new Knife()); character.Fight(); character.SetWeapon(new BowAndArrow()); character.Fight(); Console.WriteLine("\nDuck"); Duck mallard = new MallardDuck(); mallard.PerformFly(); mallard.PerformQuack(); Duck model = new ModelDuck(); model.PerformFly(); model.SetFlyBehavior(new FlyRocketPowered()); model.PerformFly(); Console.ReadKey(); }
public void ModelDuckTest() { Duck model = new ModelDuck(); Assert.Equal("I can't fly!", model.PerformFly()); model.SetFlyBehavior(new FlyRocketPowered()); Assert.Equal("Flying with powered rocket!", model.PerformFly()); }
public void ModelDuckBySetMethodTest() { var duck = new ModelDuck(); duck.PerformFly(); duck.SetFlyBehavior(new FlyRocketPowered()); duck.PerformFly(); }
public void model_duck_cannot_fly_then_add_rocket() { Duck model = new ModelDuck(); Assert.AreEqual("I can't fly.", model.PerformFly()); model.SetFlyBehaviour(new FlyRocketPowered()); Assert.AreEqual("I'm flying with a rocket!", model.PerformFly()); }
private static void RunStrategyPattern() { Duck model = new ModelDuck(); model.PerformFly(); model.PerformQuack(); model.SetFlyBehavior(new FlyRocketPowered()); model.PerformFly(); }
public void ModelDuck_Should_Change_FlyBehavior() { var modelDuck = new ModelDuck(); Assert.Equal(String.Empty, modelDuck.PerformFly()); modelDuck.FlyBehavior = new FlyRocketPowered(); Assert.Equal("rocket fly", modelDuck.PerformFly()); }
public void DucksCanChangeFlyBehavior() { ModelDuck md = new ModelDuck(); md.PerformFly(); md.PerformLand(); md.FlyBehavior = new FlyWithRockets(); md.PerformFly(); md.PerformLand(); }
public void TestMethod1() { Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Duck model = new ModelDuck(); model.PerformFly(); model.SetFlyBehavior(new FlyRocketPowered()); model.PerformFly(); }
public static void Start() { var mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); var model = new ModelDuck(); model.PerformFly(); model.FlyBehavior = new FlyRocketPowered(); model.PerformFly(); }
static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Duck model = new ModelDuck(); model.PerformFly(); model.SetFlyBehavior(new Implementations.FlyRocketPower()); model.PerformFly(); }
static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Duck model = new ModelDuck(); model.PerformFly(); model.SetFlyBehaviour(new FlyRocketPowered()); model.PerformFly(); }
public static void Run() { Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Duck model = new ModelDuck(); model.PerformFly(); model.SetFlyBehavior(new FlyRocketPowered()); model.PerformFly(); }
public void Test2() { Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Duck model = new ModelDuck(); model.PerformFly(); model.FlyBehavior = new FlyRocketPowered(); model.PerformFly(); }
static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); mallard.Display(); Console.WriteLine(); Duck model = new ModelDuck(); model.PerformFly(); model.SetFlyBehavior(new FlyRocketPowered()); model.PerformFly(); }
static void Main(string[] args) { var mallard = new MallardDuck(); mallard.Display(); mallard.PerformFly(); mallard.PerformQuack(); var modelDuck = new ModelDuck(); modelDuck.PerformFly(); modelDuck.SetFlyBehavior(new FlyRocketPowered()); modelDuck.PerformFly(); Console.ReadKey(true); }
static void Main(string[] args) { Duck duck = new MallardDuck(); duck.PerformQuack(); duck.PerformFly(); duck = new ModelDuck(); duck.PerformFly(); duck.DuckFlyBehavior = new FlyRocketPowered(); duck.PerformFly(); Console.ReadLine(); // So the console window doesn't close immediately }
public void Test1() { MallardDuck mallard = new MallardDuck(); RubberDuck rubber = new RubberDuck(); DecoyDuck decoy = new DecoyDuck(); Duck model = new ModelDuck(); mallard.PerformQuack(); rubber.PerformQuack(); decoy.PerformQuack(); model.PerformFly(); model.FlyBehavior = new FlyRocketPowered(); model.PerformFly(); }
static void Main(string[] args) { var mallard = new MallardDuck(); mallard.PerformFly(); mallard.PerformQuack(); mallard.Display(); mallard.Swim(); var modelDuck = new ModelDuck(); modelDuck.Display(); modelDuck.PerformFly(); modelDuck.FlyBehaviour = new FlyRocketPowered(); modelDuck.PerformFly(); Console.ReadLine(); }
private static void StrategyPatternRun() { Console.WriteLine(); MallardDuck mallard = new MallardDuck(); RubberDuck rubberDuckie = new RubberDuck(); DecoyDuck decoy = new DecoyDuck(); ModelDuck model = new ModelDuck(); mallard.PerformQuack(); rubberDuckie.PerformQuack(); decoy.PerformQuack(); model.PerformFly(); model.FlyBehavior = new FlyRocketPowered(); model.PerformFly(); }
public static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Duck model = new ModelDuck(); model.PerformFly(); model.FlyBehavior = new FlyRocketPowered(); model.PerformFly(); IQuackBehavior duckCall = new DuckCall(); duckCall.quack(); }
static void Main() { var mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Console.WriteLine(); Console.WriteLine("--- Dynamic behavior ---"); var model = new ModelDuck(); model.PerformFly(); model.SetFlyBehavior(new FlyRocketPowered()); model.PerformFly(); Console.ReadKey(); }
static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Duck model = new ModelDuck(); model.PerformQuack(); model.PerformFly(); model.FlyBehavior = new FlyRocketPowered(); model.PerformFly(); Console.ReadKey(); // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app! }
static void Main(string[] args) { Console.WriteLine("Simulador de patos"); Console.WriteLine("------------------"); Duck mallard = new MallardDuck(); Console.WriteLine(mallard.PerformQuack()); Console.WriteLine(mallard.PerformFly()); Duck model = new ModelDuck(); Console.WriteLine(model.PerformFly()); }
public void model_duck_cannot_fly() { Duck model = new ModelDuck(); Assert.AreEqual("I can't fly.", model.PerformFly()); }