public DuckController(MainWindow window, GameController gameController) { this.window = window; this.gameController = gameController; ducks = new ArrayList(); rnd = new Random(); dispatcher = Dispatcher.CurrentDispatcher; duckFactory = new DuckFactory(window, this); }
public void Compound_AbstractFactory() { IDuckFactory counterFactory = new DuckCounterFactory(); IDuckFactory duckFactory = new DuckFactory(); IQuackable duck1 = counterFactory.CreateDuckCall(); IQuackable duck2 = counterFactory.CreateRubberDuck(); IQuackable duck3 = duckFactory.CreateMallardDuck(); duck1.Quack(); duck2.Quack(); duck3.Quack(); Assert.AreEqual(2, QuackCounter.GetQuackCount()); }
static void Main(string[] args) { #region LiskovSubstitution Duck duck = DuckFactory.GetDuck(DuckType.Muscovy); duck.Move(); duck.Quark(); while (duck.Weight < 10) { duck.Eat(); } #endregion #region LeastKnowledge var unfriendlyStaff = new UnfriendlyStaff(); Doctor doctor = unfriendlyStaff.GetAvailableDoctor(DateTime.Today); doctor.BookTimeByPhone(DateTime.Today); var friendlyStaff = new FriendlyStaff(); friendlyStaff.BookDoctor(DateTime.Today); #endregion #region IoC var noIoC = new NoIoC(); noIoC.Running(); noIoC.RidingBike(); noIoC.Swimming(); var injectByConstructor = new InjectByConstructor(new Sprint(), new RideRoadBike(), new FreeStyleSwim()); injectByConstructor.Running(); injectByConstructor.RidingBike(); var injectBySetter = new InjectBySetter(); injectBySetter.Run = new Sprint(); injectBySetter.RideBike = new RideRoadBike(); injectByConstructor.Running(); injectByConstructor.RidingBike(); #endregion Console.ReadKey(); }
public void Compound_Composite() { DuckSimulator sim = new DuckSimulator(); Flock flockDucks = new Flock(); IDuckFactory duckFactory = new DuckFactory(); flockDucks.Add(duckFactory.CreateMallardDuck()); flockDucks.Add(duckFactory.CreateMallardDuck()); flockDucks.Add(duckFactory.CreateMallardDuck()); flockDucks.Add(duckFactory.CreateMallardDuck()); Flock flockRubberDucks = new Flock(); flockRubberDucks.Add(duckFactory.CreateRubberDuck()); flockRubberDucks.Add(duckFactory.CreateRubberDuck()); flockRubberDucks.Add(duckFactory.CreateRubberDuck()); flockDucks.Add(flockRubberDucks); sim.Simulate(flockDucks); }
public static ISubjectMethodExists <T> SubjectMethodExistsFactory <T>(ProxyModule proxyModule, Type realSubjectType) where T : class { var duckFactory = DuckFactory.FromProxyModule(proxyModule); return(duckFactory.MakeSubjectMethodExistsForDuckProxy <T>(realSubjectType)); }
public void reset() { ducks = null; ducks = new ArrayList(); duckFactory = null; duckFactory = new DuckFactory(window, this); }
public DuckFacade() { mallardDuck = DuckFactory.Create("mallard"); redheadDuck = DuckFactory.Create("redhead"); }