示例#1
0
        public GiraffeChildrenCageTestClass()
        {
            adultGiraffeCageFactory    = new AdultGiraffeCageFactory();
            childrenGiraffeCageFactory = new ChildrenGiraffeCageFactory();
            giraffeFactory             = new GiraffeFactory();

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

            giraffe = giraffeFactory.CreateAnimal() as Giraffe;
        }
        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;
            }
        }