Пример #1
0
    private static void PopulateTheZoo(List <Animal> zoo)
    {
        var command = string.Empty;

        while ((command = Console.ReadLine()) != "End")
        {
            var    input = command.Split();
            string type  = input[0];

            switch (type)
            {
            case "Owl":
                Animal currentOwl = new Owl(input[1], double.Parse(input[2]), double.Parse(input[3]));
                currentOwl.SayHungry();
                FeedAnimal(currentOwl);
                zoo.Add(currentOwl);
                break;

            case "Hen":
                Animal currentHen = new Hen(input[1], double.Parse(input[2]), double.Parse(input[3]));
                currentHen.SayHungry();
                FeedAnimal(currentHen);
                zoo.Add(currentHen);
                break;

            case "Mouse":
                Animal currentMouse = new Mouse(input[1], double.Parse(input[2]), input[3]);
                currentMouse.SayHungry();
                FeedAnimal(currentMouse);
                zoo.Add(currentMouse);
                break;

            case "Dog":
                Animal currentDog = new Dog(input[1], double.Parse(input[2]), input[3]);
                currentDog.SayHungry();
                FeedAnimal(currentDog);
                zoo.Add(currentDog);
                break;

            case "Cat":
                Animal currentCat = new Cat(input[1], double.Parse(input[2]), input[3], input[4]);
                currentCat.SayHungry();
                FeedAnimal(currentCat);
                zoo.Add(currentCat);
                break;

            case "Tiger":
                Animal currentTiger = new Tiger(input[1], double.Parse(input[2]), input[3], input[4]);
                currentTiger.SayHungry();
                FeedAnimal(currentTiger);
                zoo.Add(currentTiger);
                break;
            }
        }
    }