コード例 #1
0
        public GiraffeCageTestClass()
        {
            adultGiraffeCageFactory    = new AdultGiraffeCageFactory();
            childrenGiraffeCageFactory = new ChildrenGiraffeCageFactory();
            giraffeCageFactory         = new GiraffeCageFactory();
            giraffeFactory             = new GiraffeFactory();

            giraffeCage         = giraffeCageFactory.CreateCage() as GiraffeCage;
            giraffeAdultCage    = adultGiraffeCageFactory.CreateCage() as GiraffeAdultCage;
            giraffeChildrenCage = childrenGiraffeCageFactory.CreateCage() as GiraffeChildrenCage;

            giraffe = giraffeFactory.CreateAnimal() as Giraffe;
        }
コード例 #2
0
        public ZooTest()
        {
            zoo = Lab2Zoo.Models.Factories.ZooFactory.CreateZoo();
            giraffeCageFactory = new GiraffeCageFactory();
            giraffeFactory     = new GiraffeFactory();
            bearFactory        = new BearFactory();
            bearCageFactory    = new BearCageFactory();

            giraffe     = giraffeFactory.CreateAnimal() as Giraffe;
            bear        = bearFactory.CreateAnimal() as Bear;
            giraffeCage = giraffeCageFactory.CreateCage() as GiraffeCage;
            bearCage    = bearCageFactory.CreateCage() as BearCage;

            zoo.Add(giraffeCage);
            zoo.Add(bearCage);

            giraffeCage.Add(giraffe);
            bearCage.Add(bear);
        }
コード例 #3
0
        private void DisplayCreateContainer()
        {
            string title       = "Select type of cage:";
            string description =
                "1 : Bear cage"
                + "\n" + "2 : Bear female cage"
                + "\n" + "3 : Bear male cage"
                + "\n" + "4 : Wolf cage"
                + "\n" + "5 : White Wolf cage"
                + "\n" + "6 : Grey Wolf cage"
                + "\n" + "7 : Giraffe cage"
                + "\n" + "8 : Giraffe children cage"
                + "\n" + "9 : Giraffe adult cage"
            ;

            DisplayMenu(title, description);
            try
            {
                Container newContainer = null;
                switch (reader.GetIntNumber(0, 9))
                {
                case 0:
                {
                    DisplayMainMenu();
                    return;
                }

                case 1:
                {
                    newContainer = new BearCageFactory().CreateCage();
                    break;
                }

                case 2:
                {
                    newContainer = new FemaleBearCageFactory().CreateCage();
                    break;
                }

                case 3:
                {
                    newContainer = new MaleBearCageFactory().CreateCage();
                    break;
                }

                case 4:
                {
                    newContainer = new WolfCageFactory().CreateCage();
                    break;
                }

                case 5:
                {
                    newContainer = new WhiteWolfCageFactory().CreateCage();
                    break;
                }

                case 6:
                {
                    newContainer = new GreyWolfCageFactory().CreateCage();
                    break;
                }

                case 7:
                {
                    newContainer = new GiraffeCageFactory().CreateCage();
                    break;
                }

                case 8:
                {
                    newContainer = new ChildrenGiraffeCageFactory().CreateCage();
                    break;
                }

                case 9:
                {
                    newContainer = new AdultGiraffeCageFactory().CreateCage();
                    break;
                }
                }
                DisplaySelectContainer(currentZoo, containMe: newContainer);
            }
            catch (Exception)
            {
                throw;
            }
        }