Esempio n. 1
0
        public void Init()
        {
            duckFactory = new CountingDuckFactory();

            //QuackCounter is Decorator Pattern
            mallardDuck = duckFactory.CreateMallardDuck();
            redheadDuck = duckFactory.CreateRedheadDuck();
            duckCall = duckFactory.CreateDuckCall();
            rubberDuck = duckFactory.CreateRubberDuck();
            gooseDuck = new GooseAdapter(new Goose());//Adapter Pattern

            //Flock is Iterator Pattern
            flockOfDucks = new Flock();

            flockOfDucks.Add(redheadDuck);
            flockOfDucks.Add(duckCall);
            flockOfDucks.Add(rubberDuck);
            flockOfDucks.Add(gooseDuck);

            flockOfMallards = new Flock();

            mallardOne = duckFactory.CreateMallardDuck();
            mallardTwo = duckFactory.CreateMallardDuck();
            mallardThree = duckFactory.CreateMallardDuck();
            mallardFour = duckFactory.CreateMallardDuck();

            flockOfMallards.Add(mallardOne);
            flockOfMallards.Add(mallardTwo);
            flockOfMallards.Add(mallardThree);
            flockOfMallards.Add(mallardFour);

            flockOfDucks.Add(flockOfMallards);
        }
Esempio n. 2
0
 public void Dispose()
 {
     duckFactory = null;
     mallardDuck = null;
     redheadDuck = null;
     duckCall = null;
     rubberDuck = null;
     gooseDuck = null;
     flockOfDucks = null;
     flockOfMallards = null;
     mallardOne = null;
     mallardTwo = null;
     mallardThree = null;
     mallardFour = null;
 }