public Form1() { InitializeComponent(); Duck mallard = new MallardDuck(); mallard.PerformFly(); //textBox1.Text = mallard.PerformQuack(); textBox1.AppendText(Convert.ToString(mallard.PerformQuack()).ToString()); }
public static void UseStrategyPattern(IView view) { //the parts that vary IFlyBehavior mallardFlyBehavior = new FlyWithWings(); IQuackBehavior mallardQuack = new MallardQuack(); Duck mallard = new MallardDuck(mallardFlyBehavior, mallardQuack, view); MiniDuckSimulator duckSim = new MiniDuckSimulator(mallard); duckSim.Run(); }
static void Main(string[] args) { Duck.Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Duck.Duck model = new ModelDuck(); model.PerformQuack(); model.PerformFly(); model.SetFlyBehavior(new FlyRocketPowered()); model.PerformFly(); }
static void Main(string[] args) { // The strategy pattern defines a family of algorithms, // encapsulates each one, and makes them interchangeable. // Strategy lets the algorithm vary independently from // clients that use it. Duck mallard = new MallardDuck(); mallard.performQuack(); mallard.performFly(); Duck model = new ModelDuck(); model.performFly(); model.setFlyBehavior(new FlyRocketPowered()); model.performFly(); Console.Read(); }
public void Mallard_Duck_Test() { MallardDuck mallard = new MallardDuck(); Assert.Equal("looks like a Mallard", mallard.Display()); }