Esempio n. 1
0
        static void Main(string[] args)
        {
            Cat garidas = new Cat(2, "Garidas", Gender.Male, CatBreed.Ocicat, new List <CatFurColor>()
            {
                CatFurColor.Orange, CatFurColor.White
            }, true);
            Lion simba = new Lion(50, "Simba", Gender.Male, new List <LionFurColor>()
            {
                LionFurColor.Brown
            }, LionBreed.Asiatic, false);
            Monkey kim = new Monkey(30, "Kim", Gender.Female, new List <MonkeyFurColor>()
            {
                MonkeyFurColor.Orange, MonkeyFurColor.White
            }, MonkeyBreed.Baboon, true);
            Cat nancy = new Cat(3, "Nancy", Gender.Female, CatBreed.Ocicat, new List <CatFurColor>()
            {
                CatFurColor.Grey, CatFurColor.Black
            }, true);
            Lion bagira = new Lion(6, "Bagira", Gender.Male, new List <LionFurColor>()
            {
                LionFurColor.Brown
            }, LionBreed.Asiatic, false);
            Monkey Baloo = new Monkey(1, "Baloo", Gender.Male, new List <MonkeyFurColor>()
            {
                MonkeyFurColor.Orange, MonkeyFurColor.White
            }, MonkeyBreed.Baboon, true);

            Zoo myZoo = new Zoo("Zootopia");

            myZoo.AddAnimals(new List <Animal> {
                garidas, simba, kim, nancy, bagira, Baloo
            });

            Console.WriteLine(myZoo.GetAllAnimals());

            myZoo.SortAnimalsByAge();

            Console.WriteLine(myZoo.GetAllAnimals());
            Console.ReadKey();
        }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button butt = sender as Button;
            string n    = (string)butt.Content;

            if (n == "Voeg Aap")
            {
                Monkey monk = new Monkey();
                monk.Name = "Aapje";
                Zoo.Add(monk);
            }
            else if (n == "Voeg Leeuw")
            {
                Lion lion = new Lion();
                lion.Name = "Cecil";
                Zoo.Add(lion);
            }
            else if (n == "Voeg Olifant")
            {
                Elephant elep = new Elephant();
                elep.Name = "Oli";
                Zoo.Add(elep);
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Tender gondozo = new Tender("Tamás");

            Animal[] animalArray = new Animal[6];
            animalArray[0] = new Tiger("Sirkán", true, "Hús", true);
            animalArray[1] = new Elephant("Dumbo", false, "Növény", true);
            animalArray[2] = new Neat("Boris", false, "Növény", false);
            animalArray[3] = new Hourse("Sanyi", false, "Növény", false);
            animalArray[4] = new Lion("Szimba", true, "Hús", true);
            animalArray[5] = new Fox("Vuk", true, "Hús", false);

            for (int i = 0; i < 20; i++)
            {
                Random gen    = new Random();
                int    animal = gen.Next(0, animalArray.Length);
                Console.WriteLine(animalArray[animal].Name + " Eszik vagy iszik");
                if (animalArray[animal].Danger)
                {
                    Console.WriteLine(animalArray[animal].Name + "-t be kellet zárni");
                    Thread.Sleep(2000);
                }
                double food = gondozo.AddOrWaterFood();
                if (food == 0.0)
                {
                    Console.WriteLine(gondozo.Name + " visszamegy a Raktárba és hoz még élelmet vagy vízet!");
                    Thread.Sleep(3000);
                    gondozo.FillIn();
                }
                else
                {
                    animalArray[animal].Eat(food);

                    if (animalArray[animal].IsDead())
                    {
                        Console.WriteLine(animalArray[animal].Name + " meghalt....");
                        Thread.Sleep(2000);
                        Environment.Exit(-1);
                    }
                }
                if (animalArray[animal].NeedWater)
                {
                    double water = gondozo.AddOrWaterFood();
                    if (water == 0.0)
                    {
                        Console.WriteLine(gondozo.Name + " visszamegy a Raktárba és hoz még élelmet vagy vízet!");
                        Thread.Sleep(3000);
                        gondozo.FillIn();
                    }
                    else
                    {
                        animalArray[animal].Drink(water);

                        if (animalArray[animal].IsDead())
                        {
                            Console.WriteLine(animalArray[animal].Name + " meghalt....");
                            Thread.Sleep(5000);
                            Environment.Exit(-1);
                        }
                    }
                }
                if (animalArray[animal].Danger)
                {
                    Console.WriteLine(animalArray[animal].Name + "-t ki kell engedni");
                    Thread.Sleep(2000);
                }
            }
            Console.ReadLine();
        }