Exemple #1
0
        static void Main(string[] args)
        {
            ZooPark zoo   = new ZooPark();
            Lione   lion  = new Lione(zoo.GetManager(), 1, 10);
            Tiger   tiger = new Tiger(zoo.GetManager(), 3, 12);
            Cage    cage  = new Cage();

            cage.AddAnimal("Diego", tiger);
            cage.AddAnimal("Sam", lion);



            zoo.StartWork();
        }
Exemple #2
0
        static void MenuAnimal()
        {
            Console.WriteLine("-----------------------------");
            Console.WriteLine("chon:");
            Console.WriteLine("1. Add Cat");
            Console.WriteLine("2. Add Dog");
            Console.WriteLine("3. Add Tiger");

            Console.WriteLine("6. Exit");
            Console.WriteLine("\n----------------------------");
            Console.WriteLine("nhap so:");
            string str1 = Console.ReadLine();

            while (!int.TryParse(str1, out choose1))
            {
                Console.Write("Enter again! ");
                str1 = Console.ReadLine();
            }

            switch (choose1)
            {
            case 1:
                Console.WriteLine("cho");
                Console.Write("Enter the name of dog: ");
                string name = Console.ReadLine();

                dog = new Dog(name);
                //dog.Name = "cho";
                cage.AddAnimal(dog);
                break;
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Cage <Ape>   apeCage   = new Cage <Ape>(CageType.Glass);
            Cage <Tiger> tigerCage = new Cage <Tiger>(CageType.Gitter);
            Ape          ape       = GenericObject.GenerateObject <Ape>(new object[] { "APE", "Bert", CageType.Glass });

            apeCage.AddAnimal(ape);
            Tiger tiger = GenericObject.GenerateObject <Tiger>(new object[] { "TIGER", "Luzifer", CageType.Glass });

            tigerCage.AddAnimal(tiger);
            apeCage.RemoveAnimal(ape);
        }
Exemple #4
0
        static void Process(int choose)
        {
            zoo = new Zoo();

            switch (choose)
            {
            case 1:
            {
                Console.WriteLine("Add a new cage: ");
                Console.Write("--- Enter the cage's number: ");
                string str = Console.ReadLine();

                while (!int.TryParse(str, out cageNumber))
                {
                    Console.Write("Enter again! ");
                    str = Console.ReadLine();
                }
                MenuAnimal();


                cage = new Cage(cageNumber);
                zoo.AddAnimal(cage);
            }
            break;

            case 2:
            {
                Console.WriteLine("Enter the cage's number you want to remove: ");
                string str = Console.ReadLine();

                while (!int.TryParse(str, out cageNumber))
                {
                    Console.Write("Enter again! ");
                    str = Console.ReadLine();
                }
                zoo.RemoveCage(cageNumber);
            }
            break;

            case 3:
            {
                Console.Write("Choose 'dog'(press 1), 'cat' (press 2) or 'tiger' (press 3) to add: ");
                str = Console.ReadLine();
                int child;
                while (!int.TryParse(str, out child))
                {
                    Console.Write("Enter again! ");
                    str = Console.ReadLine();
                }
                switch (child)
                {
                case 1:
                    Console.Write("Enter the name of dog: ");
                    string name = Console.ReadLine();

                    dog = new Dog(name);
                    cage.AddAnimal(dog);
                    break;

                case 2:
                    Console.Write("Enter the name of cat: ");
                    name = Console.ReadLine();
                    cat  = new Cat(name);
                    cage.AddAnimal(cat);
                    break;

                case 3:
                    Console.Write("Enter the name of tiger: ");
                    name  = Console.ReadLine();
                    tiger = new Tiger(name);
                    cage.AddAnimal(tiger);
                    break;

                default:
                    Console.Write("Enter again! ");
                    str = Console.ReadLine();
                    break;
                }
            }
            break;

            case 4:
            {
                Console.Write("Enter the name of animal you want to remove: ");
                string name = Console.ReadLine();
                cage.RemoveAnimal(name);
            }
            break;

            case 5:
            {
                Console.WriteLine("\nIterate animal in the cage:");
                Console.Write("Animal");
                cage.IterateAnimals();
            }
            break;

            case 6:
                Console.WriteLine("Exit.");
                Environment.Exit(Environment.ExitCode);
                break;

            default:
                Console.WriteLine("Enter 1, 2, 3, 4 or 5: ");
                Menu();
                break;
            }
            Menu();
        }