public void TestMethod1() { IFlyBehaviour flyBehaviour = new FlyBehaviour(); MallardDuck mallardDuck = new MallardDuck(flyBehaviour); RedheadDuck redheadDuck = new RedheadDuck(flyBehaviour); IFlyBehaviour noFlyBehaviour = new NoFlyBehaviour(); RubberDuck rubberDuck = new RubberDuck(noFlyBehaviour); mallardDuck.Display(); mallardDuck.Fly(); redheadDuck.Display(); redheadDuck.Fly(); rubberDuck.Display(); rubberDuck.Fly(); rubberDuck.ChangeFlyBehaviour(flyBehaviour); rubberDuck.Fly(); redheadDuck.Swim(); mallardDuck.Swim(); rubberDuck.Swim(); }
static void Main(string[] args) { Duck duckMallard = new MallardDuck("José"); Duck duckRedhead = new RedheadDuck("Jaum"); Duck rubberDuck = new RubberDuck("Pedro"); duckMallard.Display(); duckMallard.Quack(); duckMallard.Swin(); duckMallard.Fly(); duckRedhead.Display(); duckRedhead.Quack(); duckRedhead.Swin(); duckRedhead.Fly(); rubberDuck.Display(); rubberDuck.Quack(); rubberDuck.Swin(); rubberDuck.Fly(); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { DbInitializer.Initialize(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred seeding the DB."); } } FlyWithWings fly = new FlyWithWings(); FlyNoWay noFly = new FlyNoWay(); MallardDuck md = new MallardDuck(fly); RedheadDuck red = new RedheadDuck(fly); RubberDuck rubberDuck = new RubberDuck(noFly); md.Display(); md.Fly(); red.Display(); red.Fly(); rubberDuck.Display(); rubberDuck.Fly(); host.Run(); }