Beispiel #1
0
        public static Food CreateFood(string input)
        {
            string[] tokens = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);

            switch (tokens[0])
            {
            case "Vegetable":
                Food newVegetable = new Vegetable(int.Parse(tokens[1]));
                return(newVegetable);

            case "Fruit":
                Food newFruit = new Fruit(int.Parse(tokens[1]));
                return(newFruit);

            case "Meat":
                Food newMeat = new Meat(int.Parse(tokens[1]));
                return(newMeat);

            case "Seeds":
                Food newSeeds = new Seeds(int.Parse(tokens[1]));
                return(newSeeds);

            default:
                return(null);
            }
        }
Beispiel #2
0
        public static Food CreateFood(string[] foodArgs)
        {
            int quantity = int.Parse(foodArgs[1]);

            switch (foodArgs[0])
            {
            case "Vegetable":
                Vegetable vegetable = new Vegetable(quantity);
                return(vegetable);

            case "Fruit":
                Fruit fruit = new Fruit(quantity);
                return(fruit);

            case "Meat":
                Meat meat = new Meat(quantity);
                return(meat);

            case "Seeds":
                Seeds seeds = new Seeds(quantity);
                return(seeds);

            default:
                return(null);
            }
        }
Beispiel #3
0
        private static Food CreateFood(string[] parts, Food food)
        {
            string foodType = parts[0];
            int    quantity = int.Parse(parts[1]);


            if (foodType == "Vegetable")
            {
                food = new Vegetable(quantity);
            }
            else if (foodType == "Fruit")
            {
                food = new Fruit(quantity);
            }
            else if (foodType == "Meat")
            {
                food = new Meat(quantity);
            }
            else if (foodType == "Seeds")
            {
                food = new Seeds(quantity);
            }

            return(food);
        }
Beispiel #4
0
        public static Food CreateFood(string[] foodInfo)
        {
            Food food;

            switch (foodInfo[0])
            {
            case "Fruit":
                food = new Fruit(int.Parse(foodInfo[1]));
                break;

            case "Vegetable":
                food = new Vegetable(int.Parse(foodInfo[1]));
                break;

            case "Meat":
                food = new Meat(int.Parse(foodInfo[1]));
                break;

            case "Seeds":
                food = new Seeds(int.Parse(foodInfo[1]));
                break;

            default:
                throw new ArgumentException("Invalid food type!");
            }

            return(food);
        }
Beispiel #5
0
        private static Food CreateFood(string[] foodInput)
        {
            Food food     = null;
            var  type     = foodInput[0];
            var  quantity = int.Parse(foodInput[1]);

            if (type == nameof(Fruit))
            {
                food = new Fruit(quantity);
            }
            else if (type == nameof(Meat))
            {
                food = new Meat(quantity);
            }
            else if (type == nameof(Seeds))
            {
                food = new Seeds(quantity);
            }
            else if (type == nameof(Vegetable))
            {
                food = new Vegetable(quantity);
            }

            return(food);
        }
Beispiel #6
0
        private static Food CreateFood(string[] foodParts)
        {
            string type     = foodParts[0];
            int    quantity = int.Parse(foodParts[1]);

            Food food = null;

            if (type == nameof(Meat))
            {
                food = new Meat(quantity);
            }
            else if (type == nameof(Vegetable))
            {
                food = new Vegetable(quantity);
            }
            else if (type == nameof(Fruit))
            {
                food = new Fruit(quantity);
            }
            else if (type == nameof(Seeds))
            {
                food = new Seeds(quantity);
            }

            return(food);
        }
        public static Food CreateFood(string[] foodInfo)
        {
            Food   food     = null;
            string type     = foodInfo[0];
            int    quantity = int.Parse(foodInfo[1]);

            if (type == "Fruit")
            {
                food = new Fruit(quantity);
            }
            else if (type == "Meat")
            {
                food = new Meat(quantity);
            }
            else if (type == "Seeds")
            {
                food = new Seeds(quantity);
            }
            else if (type == "Vegetable")
            {
                food = new Vegetable(quantity);
            }

            return(food);
        }
Beispiel #8
0
        private static Food InitFood(string command, Food food)
        {
            try
            {
                string[] foodData = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                string   foodType = foodData[0];
                int.TryParse(foodData[1], out int foodQty);

                switch (foodType)
                {
                case "Meat":
                    food = new Meat(foodQty);
                    break;

                case "Vegetable":
                    food = new Vegetable(foodQty);
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(food);
        }
Beispiel #9
0
        private static Food ReadFood(string str)
        {
            var data = str.Split();

            string type   = data[0];
            int    amount = int.Parse(data[1]);

            Food food = null;

            if (type == "Vegetable")
            {
                food = new Vegetable(amount);
            }
            else if (type == "Fruit")
            {
                food = new Fruit(amount);
            }
            else if (type == "Seeds")
            {
                food = new Seeds(amount);
            }
            else if (type == "Meat")
            {
                food = new Meat(amount);
            }

            return(food);
        }
Beispiel #10
0
        public static Food CreateFood(string[] foodInputSplitted)
        {
            var foodType = foodInputSplitted[0];
            int quantity = int.Parse(foodInputSplitted[1]);

            if (foodType == "Vegetable")
            {
                Food food = new Vegetable(quantity);
                return(food);
            }
            else
            {
                Food food = new Meat(quantity);
                return(food);
            }
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            Animal animal = null;
            Food   food   = null;
            string input  = Console.ReadLine();

            //string foods = Console.ReadLine();
            while (input != "End")
            {
                string[] line   = input.Split(new[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                string[] str    = Console.ReadLine().Split(' ');
                string   type   = line[0];
                string   name   = line[1];
                double   weight = double.Parse(line[2]);
                string   region = line[3];
                switch (type.ToLower())
                {
                case "cat":
                    string breed = line[4];
                    animal = new Cat(name, type, weight, region, breed); break;

                case "mouse":
                    animal = new Mouse(name, type, weight, region); break;

                case "tiger":
                    animal = new Tiger(name, type, weight, region); break;

                case "zebra":
                    animal = new Zebra(name, type, weight, region); break;
                }

                var vg = str[0];
                int r  = int.Parse(str[1]);
                if (vg == "Meat")
                {
                    food = new Meat(r);
                }
                else
                {
                    food = new Vegetable(r);
                }
                animal.MakeSound();
                animal.Eat(food);
                Console.WriteLine(animal);
                input = Console.ReadLine();
            }
        }
Beispiel #12
0
        static void Main()
        {
            var    animalsFactory = new AnimalFactory();
            string input;

            while ((input = Console.ReadLine()) != "End")
            {
                var    tokens        = input.Split();
                Animal currentAnimal = null;
                currentAnimal = animalsFactory.CreateAnimal(tokens);
                if (currentAnimal != null)
                {
                    list.Add(currentAnimal);
                    Console.WriteLine(currentAnimal.MakeSound());
                    var  foodTokens  = Console.ReadLine().Split();
                    Food currentFood = null;
                    switch (foodTokens[0])
                    {
                    case "Vegetable":
                        currentFood = new Vegetable(int.Parse(foodTokens[1]));
                        break;

                    case "Fruit":
                        currentFood = new Fruit(int.Parse(foodTokens[1]));
                        break;

                    case "Meat":
                        currentFood = new Meat(int.Parse(foodTokens[1]));
                        break;

                    case "Seeds":
                        currentFood = new Seeds(int.Parse(foodTokens[1]));
                        break;
                    }
                    try
                    {
                        currentAnimal.Feed(currentFood);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }
            Console.WriteLine(string.Join(Environment.NewLine, list));
        }
        static void Main(string[] args)
        {
            Queue <Animal> animals     = new Queue <Animal>();
            List <Animal>  listAnimals = new List <Animal>();

            var input = Console.ReadLine().Split(" ").ToArray();

            while (input[0] != "End")
            {
                if (input.Length > 2)
                {
                    switch (input[0])
                    {
                    case "Hen":
                    {
                        Hen hen = new Hen(input[1], double.Parse(input[2]), double.Parse(input[3]));
                        hen.WantFood();

                        animals.Enqueue(hen);
                        break;
                    }

                    case "Owl":
                    {
                        Owl owl = new Owl(input[1], double.Parse(input[2]), double.Parse(input[3]));
                        owl.WantFood();

                        animals.Enqueue(owl);
                        break;
                    }

                    case "Mouse":
                    {
                        Mouse mouse = new Mouse(input[1], double.Parse(input[2]), input[3]);
                        mouse.WantFood();

                        animals.Enqueue(mouse);
                        break;
                    }

                    case "Cat":
                    {
                        Cat cat = new Cat(input[1], double.Parse(input[2]), input[3], input[4]);
                        cat.WantFood();

                        animals.Enqueue(cat);
                        break;
                    }

                    case "Dog":
                    {
                        Dog dog = new Dog(input[1], double.Parse(input[2]), input[3]);
                        dog.WantFood();

                        animals.Enqueue(dog);
                        break;
                    }

                    case "Tiger":
                    {
                        Tiger tiger = new Tiger(input[1], double.Parse(input[2]), input[3], input[4]);
                        tiger.WantFood();

                        animals.Enqueue(tiger);
                        break;
                    }
                    }
                }
                else
                {
                    switch (input[0])
                    {
                    case "Vegetable":
                    {
                        Vegetable vegetable = new Vegetable(int.Parse(input[1]));

                        var animal = animals.Dequeue();
                        listAnimals.Add(animal);
                        animal.Eat(vegetable);
                        break;
                    }

                    case "Fruit":
                    {
                        Fruit fruit = new Fruit(int.Parse(input[1]));

                        var animal = animals.Dequeue();
                        listAnimals.Add(animal);
                        animal.Eat(fruit);
                        break;
                    }

                    case "Meat":
                    {
                        Meat meat = new Meat(int.Parse(input[1]));

                        var animal = animals.Dequeue();
                        listAnimals.Add(animal);
                        animal.Eat(meat);
                        break;
                    }

                    case "Seeds":
                    {
                        Seeds seeds = new Seeds(int.Parse(input[1]));

                        var animal = animals.Dequeue();
                        listAnimals.Add(animal);
                        animal.Eat(seeds);
                        break;
                    }
                    }
                }

                input = Console.ReadLine().Split(" ").ToArray();
            }

            foreach (var animal in listAnimals)
            {
                Console.WriteLine(animal.ToString());
            }
        }
        static void Main()
        {
            var animalInfo = Console.ReadLine()
                             .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            while (!animalInfo[0].Equals("End"))
            {
                var foodInfo = Console.ReadLine()
                               .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                var animalName         = animalInfo[1];
                var animalWeight       = double.Parse(animalInfo[2]);
                var animalLivingRegion = animalInfo[3];

                var foodType     = foodInfo[0];
                var foodQuantity = int.Parse(foodInfo[1]);

                Food food;
                if (foodType.Equals("Vegetable"))
                {
                    food = new Vegetable(foodQuantity);
                }
                else
                {
                    food = new Meat(foodQuantity);
                }

                switch (animalInfo[0])
                {
                case "Cat":
                    var catBreed = animalInfo[4];

                    var cat = new Cat(animalName, animalWeight, animalLivingRegion, catBreed);
                    cat.MakeSound();
                    cat.Eat(food);
                    Console.WriteLine(cat);
                    break;

                case "Tiger":
                    var tiger = new Tiger(animalName, animalWeight, animalLivingRegion);
                    tiger.MakeSound();
                    tiger.Eat(food);
                    Console.WriteLine(tiger);
                    break;

                case "Zebra":
                    var zebra = new Zebra(animalName, animalWeight, animalLivingRegion);
                    zebra.MakeSound();
                    zebra.Eat(food);
                    Console.WriteLine(zebra);
                    break;

                case "Mouse":
                    var mouse = new Mouse(animalName, animalWeight, animalLivingRegion);
                    mouse.MakeSound();
                    mouse.Eat(food);
                    Console.WriteLine(mouse);
                    break;
                }

                animalInfo = Console.ReadLine()
                             .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            }
        }
        public void Run()
        {
            var animals = new List <Animal>();
            var counter = 0;

            while (true)
            {
                var command = Console.ReadLine().Split();

                if (command[0] == "End")
                {
                    break;
                }
                if (counter % 2 == 0)
                {
                    if (command[0] == "Hen")
                    {
                        var name     = command[1];
                        var weight   = double.Parse(command[2]);
                        var wingSize = double.Parse(command[3]);

                        var currHen = new Hen(name, weight, wingSize);
                        animals.Add(currHen);
                    }
                    else if (command[0] == "Owl")
                    {
                        var name     = command[1];
                        var weight   = double.Parse(command[2]);
                        var wingSize = double.Parse(command[3]);

                        var currOwl = new Owl(name, weight, wingSize);
                        animals.Add(currOwl);
                    }
                    else if (command[0] == "Mouse")
                    {
                        var name         = command[1];
                        var weight       = double.Parse(command[2]);
                        var livingRegion = command[3];

                        var currMouse = new Mouse(name, weight, livingRegion);
                        animals.Add(currMouse);
                    }
                    else if (command[0] == "Cat")
                    {
                        var name         = command[1];
                        var weight       = double.Parse(command[2]);
                        var livingRegion = command[3];
                        var breed        = command[4];

                        var currCat = new Cat(name, weight, livingRegion, breed);
                        animals.Add(currCat);
                    }
                    else if (command[0] == "Dog")
                    {
                        var name         = command[1];
                        var weight       = double.Parse(command[2]);
                        var livingRegion = command[3];

                        var currDog = new Dog(name, weight, livingRegion);
                        animals.Add(currDog);
                    }
                    else if (command[0] == "Tiger")
                    {
                        var name         = command[1];
                        var weight       = double.Parse(command[2]);
                        var livingRegion = command[3];
                        var breed        = command[4];

                        var currTiger = new Tiger(name, weight, livingRegion, breed);
                        animals.Add(currTiger);
                    }
                    Console.WriteLine(animals.Last().ProduceSound());
                }
                else
                {
                    var lastAnimal = animals.Last().GetType().Name;

                    if (command[0] == "Fruit")
                    {
                        var quantity  = int.Parse(command[1]);
                        var currFruit = new Fruit(quantity);

                        if (lastAnimal == "Hen" || lastAnimal == "Mouse")
                        {
                            HenEating(animals, quantity);
                            MouseEating(animals, quantity);
                        }
                        else
                        {
                            Console.WriteLine($"{lastAnimal} does not eat Fruit!");
                        }
                    }
                    else if (command[0] == "Meat")
                    {
                        var quantity = int.Parse(command[1]);
                        var currMeat = new Meat(quantity);

                        if (lastAnimal == "Hen" || lastAnimal == "Cat" ||
                            lastAnimal == "Tiger" || lastAnimal == "Dog" || lastAnimal == "Owl")
                        {
                            HenEating(animals, quantity);
                            CatEating(animals, quantity);
                            TigerEating(animals, quantity);
                            DogEating(animals, quantity);
                            OwlEating(animals, quantity);
                        }
                        else
                        {
                            Console.WriteLine($"{lastAnimal} does not eat Meat!");
                        }
                    }
                    else if (command[0] == "Seeds")
                    {
                        var quantity  = int.Parse(command[1]);
                        var currSeeds = new Seeds(quantity);

                        if (lastAnimal == "Hen")
                        {
                            HenEating(animals, quantity);
                        }
                        else
                        {
                            Console.WriteLine($"{lastAnimal} does not eat Seeds!");
                        }
                    }
                    else if (command[0] == "Vegetable")
                    {
                        var quantity      = int.Parse(command[1]);
                        var currVegetable = new Vegetable(quantity);

                        if (lastAnimal == "Mouse" || lastAnimal == "Hen" || lastAnimal == "Cat")
                        {
                            HenEating(animals, quantity);
                            MouseEating(animals, quantity);
                            CatEating(animals, quantity);
                        }
                        else
                        {
                            Console.WriteLine($"{lastAnimal} does not eat Vegetable!");
                        }
                    }
                }
                counter++;
            }
            foreach (var animal in animals)
            {
                Console.WriteLine(animal);
            }
        }
Beispiel #16
0
        static void Main(string[] args)
        {
            List <Animal> animals = new List <Animal>();

            while (true)
            {
                string input = Console.ReadLine();
                if (input == "End")
                {
                    break;
                }
                string[] dataAnimal = input.Split();
                string[] dataFood   = Console.ReadLine().Split();
                string   type       = dataAnimal[0];
                string   name       = dataAnimal[1];
                double   weight     = double.Parse(dataAnimal[2]);
                Animal   animal     = null;
                if (type == nameof(Owl))
                {
                    animal = new Owl(name, weight, double.Parse(dataAnimal[3]));
                }
                else if (type == nameof(Hen))
                {
                    animal = new Hen(name, weight, double.Parse(dataAnimal[3]));
                }
                else if (type == nameof(Mouse))
                {
                    animal = new Mouse(name, weight, dataAnimal[3]);
                }
                else if (type == nameof(Dog))
                {
                    animal = new Dog(name, weight, dataAnimal[3]);
                }
                else if (type == nameof(Cat))
                {
                    animal = new Cat(name, weight, dataAnimal[3], dataAnimal[4]);
                }
                else if (type == nameof(Tiger))
                {
                    animal = new Tiger(name, weight, dataAnimal[3], dataAnimal[4]);
                }
                string foodType = dataFood[0];
                int    quantity = int.Parse(dataFood[1]);
                Food   food     = null;
                if (foodType == nameof(Meat))
                {
                    food = new Meat(quantity);
                }
                else if (foodType == nameof(Vegetable))
                {
                    food = new Vegetable(quantity);
                }
                else if (foodType == nameof(Fruit))
                {
                    food = new Fruit(quantity);
                }
                else if (foodType == nameof(Seeds))
                {
                    food = new Seeds(quantity);
                }
                Console.WriteLine(animal.ProduceSound());
                animal.EatingFood(food);
                animals.Add(animal);
            }
            foreach (var animal in animals)
            {
                Console.WriteLine(animal);
            }
        }
Beispiel #17
0
        static void Main(string[] args)
        {
            var animals = new List <Animal>();

            while (true)
            {
                string[] animalInput = Console.ReadLine().Split();
                if (animalInput[0] == "End")
                {
                    break;
                }

                string[] foodInput = Console.ReadLine().Split();

                Animal animal = null;
                Food   food   = null;

                string type   = animalInput[0];
                string name   = animalInput[1];
                double weight = double.Parse(animalInput[2]);

                switch (type)
                {
                case "Owl":
                    animal = new Owl(name, weight, double.Parse(animalInput[3]));
                    break;

                case "Hen":
                    animal = new Hen(name, weight, double.Parse(animalInput[3]));
                    break;

                case "Mouse":
                    animal = new Mouse(name, weight, animalInput[3]);
                    break;

                case "Dog":
                    animal = new Dog(name, weight, animalInput[3]);
                    break;

                case "Cat":
                    animal = new Cat(name, weight, animalInput[3], animalInput[4]);
                    break;

                case "Tiger":
                    animal = new Tiger(name, weight, animalInput[3], animalInput[4]);
                    break;

                default:
                    break;
                }

                string foodType     = foodInput[0];
                int    foodQuantity = int.Parse(foodInput[1]);

                switch (foodType)
                {
                case "Fruit":
                    food = new Fruit(foodQuantity);
                    break;

                case "Vegetable":
                    food = new Vegetable(foodQuantity);
                    break;

                case "Meat":
                    food = new Meat(foodQuantity);
                    break;

                case "Seeds":
                    food = new Seeds(foodQuantity);
                    break;

                default:
                    break;
                }

                Console.WriteLine(animal.AskForFood());
                animal.Feed(food);

                animals.Add(animal);
            }

            foreach (var animal in animals)
            {
                Console.WriteLine(animal.ToString());
            }
        }
        public static void Main()
        {
            List <Animal> animals = new List <Animal>();
            List <Food>   foods   = new List <Food>();

            int lineCounter = -1;

            while (true)
            {
                lineCounter++;//N.B. += 1
                string cmd = Console.ReadLine();
                if (cmd == "End")
                {
                    break;
                }

                string[] cmdArgs = cmd.Split(' ', StringSplitOptions.RemoveEmptyEntries);

                switch (cmdArgs[0])
                {
                case "Owl":
                    var owl = new Owl(cmdArgs[1], double.Parse(cmdArgs[2]), double.Parse(cmdArgs[3]));
                    animals.Add(owl);
                    break;

                case "Hen":
                    var hen = new Hen(cmdArgs[1], double.Parse(cmdArgs[2]), double.Parse(cmdArgs[3]));
                    animals.Add(hen);
                    break;

                case "Mouse":
                    var mouse = new Mouse(cmdArgs[1], double.Parse(cmdArgs[2]), cmdArgs[3]);
                    animals.Add(mouse);
                    break;

                case "Dog":
                    var dog = new Dog(cmdArgs[1], double.Parse(cmdArgs[2]), cmdArgs[3]);
                    animals.Add(dog);
                    break;

                case "Cat":
                    var cat = new Cat(cmdArgs[1], double.Parse(cmdArgs[2]), cmdArgs[3], cmdArgs[4]);
                    animals.Add(cat);
                    break;

                case "Tiger":
                    var tiger = new Tiger(cmdArgs[1], double.Parse(cmdArgs[2]), cmdArgs[3], cmdArgs[4]);
                    animals.Add(tiger);
                    break;

                case "Vegetable":
                    var vegetable = new Vegetable(int.Parse(cmdArgs[1]));
                    foods.Add(vegetable);
                    break;

                case "Fruit":
                    var fruit = new Fruit(int.Parse(cmdArgs[1]));
                    foods.Add(fruit);
                    break;

                case "Meat":
                    var meat = new Meat(int.Parse(cmdArgs[1]));
                    foods.Add(meat);
                    break;

                case "Seeds":
                    var seeds = new Seeds(int.Parse(cmdArgs[1]));
                    foods.Add(seeds);
                    break;
                }
            }

            for (int i = 0; i < animals.Count; i++)
            {
                try
                {
                    Console.WriteLine(animals[i].AskForFood());
                    animals[i].Eat(foods[i]);
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            animals.ForEach(Console.WriteLine);
        }
        static void Main(string[] args)
        {
            var animals = new List <Animal>();

            while (true)
            {
                string cmd = Console.ReadLine();

                if (cmd == "End")
                {
                    break;
                }

                var    data       = cmd.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string animalType = data[0];
                string name       = data[1];
                double weight     = double.Parse(data[2]);

                Animal animal = null;

                switch (animalType)
                {
                case "Owl":
                {
                    int wingSize = int.Parse(data[3]);

                    animal = new Owl(name, weight, wingSize);
                    break;
                }

                case "Hen":
                {
                    int wingSize = int.Parse(data[3]);

                    animal = new Hen(name, weight, wingSize);
                    break;
                }

                case "Mouse":
                {
                    string region = data[3];

                    animal = new Mouse(name, weight, region);
                    break;
                }

                case "Dog":
                {
                    string region = data[3];

                    animal = new Dog(name, weight, region);
                    break;
                }

                case "Cat":
                {
                    string region = data[3];
                    string breed  = data[4];

                    animal = new Cat(name, weight, region, breed);
                    break;
                }

                case "Tiger":
                {
                    string region = data[3];
                    string breed  = data[4];

                    animal = new Tiger(name, weight, region, breed);
                    break;
                }

                default:
                    break;
                }

                Console.WriteLine(animal.ProduceSound());

                var foodData = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

                string foodName = foodData[0];
                int    foodNum  = int.Parse(foodData[1]);

                Food food = null;

                switch (foodName)
                {
                case "Fruit":
                {
                    food = new Fruit(foodNum);

                    break;
                }

                case "Meat":
                {
                    food = new Meat(foodNum);
                    break;
                }

                case "Seeds":
                {
                    food = new Seeds(foodNum);
                    break;
                }

                case "Vegetable":
                {
                    food = new Vegetable(foodNum);
                    break;
                }

                default:
                    break;
                }

                animal.Feed(food);
                animals.Add(animal);
            }

            foreach (var beast in animals)
            {
                Console.WriteLine(beast.ToString());
            }
        }
Beispiel #20
0
        static void Main(string[] args)
        {
            List <Animal> animals = new List <Animal>();

            while (true)
            {
                string input = Console.ReadLine();
                if (input == "End")
                {
                    break;
                }
                string[] currentAnimal = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string[] currentFood   = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
                try
                {
                    Animal animal       = null;
                    string typeOfAnimal = currentAnimal[0];
                    string animalName   = currentAnimal[1];
                    double animalWeight = double.Parse(currentAnimal[2]);
                    double wingSize;
                    string livingRegion;
                    string breed;
                    switch (typeOfAnimal)
                    {
                    case "Hen":
                        wingSize = double.Parse(currentAnimal[3]);
                        animal   = new Hen(animalName, animalWeight, wingSize);
                        break;

                    case "Owl":
                        wingSize = double.Parse(currentAnimal[3]);
                        animal   = new Owl(animalName, animalWeight, wingSize);
                        break;

                    case "Dog":
                        livingRegion = currentAnimal[3];
                        animal       = new Dog(animalName, animalWeight, livingRegion);
                        break;

                    case "Mouse":
                        livingRegion = currentAnimal[3];
                        animal       = new Mouse(animalName, animalWeight, livingRegion);
                        break;

                    case "Cat":
                        livingRegion = currentAnimal[3];
                        breed        = currentAnimal[4];
                        animal       = new Cat(animalName, animalWeight, livingRegion, breed);
                        break;

                    case "Tiger":
                        livingRegion = currentAnimal[3];
                        breed        = currentAnimal[4];
                        animal       = new Tiger(animalName, animalWeight, livingRegion, breed);
                        break;
                    }
                    animals.Add(animal);

                    Food   food         = null;
                    string typeOfFood   = currentFood[0];
                    int    foodQuantity = int.Parse(currentFood[1]);
                    switch (typeOfFood)
                    {
                    case "Vegetable":
                        food = new Vegetable(foodQuantity);
                        break;

                    case "Seeds":
                        food = new Seeds(foodQuantity);
                        break;

                    case "Fruit":
                        food = new Fruit(foodQuantity);
                        break;

                    case "Meat":
                        food = new Meat(foodQuantity);
                        break;

                    default:
                        break;
                    }

                    Console.WriteLine(animal.ProduceSound());
                    animal.ValidateFood(food);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            foreach (Animal animal in animals)
            {
                Console.WriteLine(animal.ToString());
            }
        }
Beispiel #21
0
        static void Main(string[] args)
        {
            int    counter = 0;
            string line    = string.Empty;

            List <Animal> animals = new List <Animal>();

            while ((line = Console.ReadLine()) != "End")
            {
                var information = line.Split(" ");

                counter++;

                if (counter % 2 != 0)
                {
                    string type   = information[0];
                    string name   = information[1];
                    double weight = double.Parse(information[2]);

                    Animal animal = null;

                    switch (type)
                    {
                    case "Owl":
                        double wingSize = double.Parse(information[3]);
                        animal = new Owl(name, weight, wingSize);
                        break;

                    case "Hen":
                        double wingSizes = double.Parse(information[3]);
                        animal = new Hen(name, weight, wingSizes);
                        break;

                    case "Mouse":
                        string livingRegion = information[3];
                        animal = new Mouse(name, weight, livingRegion);
                        break;

                    case "Dog":
                        string livingRegiones = information[3];
                        animal = new Dog(name, weight, livingRegiones);
                        break;

                    case "Cat":
                        string livingRegions = information[3];
                        string breed         = information[4];
                        animal = new Cat(name, weight, livingRegions, breed);
                        break;

                    case "Tiger":
                        string livingRegionse = information[3];
                        string breeds         = information[4];
                        animal = new Tiger(name, weight, livingRegionse, breeds);
                        break;
                    }

                    animals.Add(animal);
                }
                else
                {
                    string foodName = information[0];
                    int    quantity = int.Parse(information[1]);

                    Food food = null;

                    switch (foodName)
                    {
                    case "Vegetable": food = new Vegetable(quantity); break;

                    case "Seeds": food = new Seeds(quantity); break;

                    case "Meat": food = new Meat(quantity); break;

                    case "Fruit": food = new Fruit(quantity); break;
                    }

                    Animal currentAnimal = animals[(counter / 2) - 1];
                    Console.WriteLine(currentAnimal.AskFood());

                    try
                    {
                        currentAnimal.Feed(food);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }

            foreach (var animal in animals)
            {
                Console.WriteLine(animal);
            }
        }
Beispiel #22
0
        public static void Main()
        {
            List <Animal> animals = new List <Animal>();
            List <Food>   foods   = new List <Food>();

            int lineNum = 0;

            while (true)
            {
                string line = Console.ReadLine();
                if (line == "End")
                {
                    break;
                }

                Animal animal = null;
                Food   food   = null;
                if (lineNum % 2 == 0)
                {
                    string[] animalArgs = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                    lineNum++;

                    string type   = animalArgs[0];
                    string name   = animalArgs[1];
                    double weight = double.Parse(animalArgs[2]);
                    switch (type)
                    {
                    // {LivingRegion} {Breed}
                    case "Cat":
                        string livingRegion = animalArgs[3];
                        string breed        = animalArgs[4];

                        animal = new Cat(name, weight, livingRegion, breed);
                        break;

                    case "Tiger":
                        livingRegion = animalArgs[3];
                        breed        = animalArgs[4];

                        animal = new Tiger(name, weight, livingRegion, breed);
                        break;

                    case "Owl":
                        double wingSize = double.Parse(animalArgs[3]);

                        animal = new Owl(name, weight, wingSize);
                        break;

                    case "Hen":
                        wingSize = double.Parse(animalArgs[3]);

                        animal = new Hen(name, weight, wingSize);
                        break;

                    case "Mouse":
                        livingRegion = animalArgs[3];

                        animal = new Mouse(name, weight, livingRegion);
                        break;

                    case "Dog":
                        livingRegion = animalArgs[3];

                        animal = new Dog(name, weight, livingRegion);
                        break;
                    }

                    animals.Add(animal);
                }
                else
                {
                    string[] foodArgs = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                    lineNum++;

                    string foodType = foodArgs[0];
                    int    quantity = int.Parse(foodArgs[1]);
                    switch (foodType)
                    {
                    case "Vegetable":
                        food = new Vegetable(quantity);
                        break;

                    case "Fruit":
                        food = new Fruit(quantity);
                        break;

                    case "Meat":
                        food = new Meat(quantity);
                        break;

                    case "Seeds":
                        food = new Seeds(quantity);
                        break;
                    }

                    foods.Add(food);
                }
            }

            for (int i = 0; i < animals.Count; i++)
            {
                try
                {
                    Console.WriteLine(animals[i].AskForFood());
                    animals[i].Eat(foods[i]);
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            animals.ForEach(Console.WriteLine);
        }
        static void Main(string[] args)
        {
            List <Animal> animals = new List <Animal>();

            while (true)
            {
                string command = Console.ReadLine();

                if (command.Equals("End"))
                {
                    break;
                }

                string[] inputInfo = command.Split().ToArray();

                string animalType = inputInfo[0];
                string name       = inputInfo[1];
                double weight     = double.Parse(inputInfo[2]);

                string[] food     = Console.ReadLine().Split().ToArray();
                string   foodType = food[0];
                int      quantity = int.Parse(food[1]);

                IFood  currentFood = null;
                Animal animal      = null;

                if (foodType.Equals("Vegetable"))
                {
                    currentFood = new Vegetable(quantity);
                }
                else if (foodType.Equals("Fruit"))
                {
                    currentFood = new Fruit(quantity);
                }
                else if (foodType.Equals("Meat"))
                {
                    currentFood = new Meat(quantity);
                }
                else if (foodType.Equals("Seeds"))
                {
                    currentFood = new Seeds(quantity);
                }


                if (animalType.Equals("Hen"))
                {
                    double wingSize = double.Parse(inputInfo[3]);

                    animal = new Hen(name, weight, wingSize);
                }
                else if (animalType.Equals("Owl"))
                {
                    double wingSize = double.Parse(inputInfo[3]);

                    animal = new Owl(name, weight, wingSize);
                }
                else if (animalType.Equals("Mouse"))
                {
                    string livingRegion = inputInfo[3];

                    animal = new Mouse(name, weight, livingRegion);
                }
                else if (animalType.Equals("Dog"))
                {
                    string livingRegion = inputInfo[3];

                    animal = new Dog(name, weight, livingRegion);
                }
                else if (animalType.Equals("Cat"))
                {
                    string livingRegion = inputInfo[3];
                    string breed        = inputInfo[4];

                    animal = new Cat(name, weight, livingRegion, breed);
                }
                else if (animalType.Equals("Tiger"))
                {
                    string livingRegion = inputInfo[3];
                    string breed        = inputInfo[4];

                    animal = new Tiger(name, weight, livingRegion, breed);
                }

                animals.Add(animal);

                animal.ProduceSound();
                try
                {
                    animal.Eating(currentFood);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            foreach (var animal in animals)
            {
                Console.WriteLine(animal);
            }
        }
Beispiel #24
0
        static void Main(string[] args)
        {
            string input       = string.Empty;
            int    counter     = 0;
            var    listAnimals = new Stack <Animal>();
            var    listFood    = new Stack <Food>();

            while ((input = Console.ReadLine()) != "End")
            {
                if (counter % 2 == 0)
                {
                    var tokens = input
                                 .Split()
                                 .ToArray();

                    string animalType   = tokens[0];
                    string animalName   = tokens[1];
                    double animalWeight = double.Parse(tokens[2]);

                    if (animalType == "Owl")
                    {
                        double wingSize = double.Parse(tokens[3]);
                        Owl    owl      = new Owl(animalName, animalWeight, wingSize);
                        owl.Sound();
                        listAnimals.Push(owl);
                    }
                    else if (animalType == "Hen")
                    {
                        double wingSize = double.Parse(tokens[3]);
                        Hen    hen      = new Hen(animalName, animalWeight, wingSize);
                        hen.Sound();
                        listAnimals.Push(hen);
                    }
                    else if (animalType == "Mouse")
                    {
                        string livingRegion = tokens[3];
                        Mouse  mouse        = new Mouse(animalName, animalWeight, livingRegion);
                        mouse.Sound();
                        listAnimals.Push(mouse);
                    }
                    else if (animalType == "Dog")
                    {
                        string livingRegion = tokens[3];
                        Dog    dog          = new Dog(animalName, animalWeight, livingRegion);
                        dog.Sound();
                        listAnimals.Push(dog);
                    }
                    else if (animalType == "Cat")
                    {
                        string livingRegion = tokens[3];
                        string breed        = tokens[4];
                        Cat    cat          = new Cat(animalName, animalWeight, livingRegion, breed);
                        cat.Sound();
                        listAnimals.Push(cat);
                    }
                    else if (animalType == "Tiger")
                    {
                        string livingRegion = tokens[3];
                        string breed        = tokens[4];
                        Tiger  tiger        = new Tiger(animalName, animalWeight, livingRegion, breed);
                        tiger.Sound();
                        listAnimals.Push(tiger);
                    }
                }
                else if (counter % 2 != 0)
                {
                    var token = input
                                .Split()
                                .ToArray();

                    string foodType = token[0];
                    int    quantity = int.Parse(token[1]);

                    if (foodType == "Vegetable")
                    {
                        Vegetable vegetable = new Vegetable(quantity);
                        listFood.Push(vegetable);
                    }
                    else if (foodType == "Fruit")
                    {
                        Fruit fruit = new Fruit(quantity);
                        listFood.Push(fruit);
                    }
                    else if (foodType == "Meat")
                    {
                        Meat meat = new Meat(quantity);
                        listFood.Push(meat);
                    }
                    else if (foodType == "Seeds")
                    {
                        Seeds seeds = new Seeds(quantity);
                        listFood.Push(seeds);
                    }
                }

                if (counter % 2 != 0)
                {
                    listAnimals.Peek().Eat(listFood.Peek());
                }

                counter++;
            }

            while (listAnimals.Count > 0)
            {
                Console.WriteLine(listAnimals.Pop().ToString());
            }
        }
Beispiel #25
0
        public static void Main()
        {
            var animals = new List <Animal>();

            string inputLine;

            while ((inputLine = Console.ReadLine()) != "End")
            {
                var    input  = inputLine.Split();
                Animal animal = null;
                Food   food   = null;

                var animalType = input[0];
                var name       = input[1];
                var weight     = double.Parse(input[2]);

                switch (animalType)
                {
                case nameof(Owl):
                    animal = new Owl(name, weight, double.Parse(input[3]));
                    break;

                case nameof(Hen):
                    animal = new Hen(name, weight, double.Parse(input[3]));
                    break;

                case nameof(Mouse):
                    animal = new Mouse(name, weight, input[3]);
                    break;

                case nameof(Dog):
                    animal = new Dog(name, weight, input[3]);
                    break;

                case nameof(Cat):
                    animal = new Cat(name, weight, input[3], input[4]);
                    break;

                case nameof(Tiger):
                    animal = new Tiger(name, weight, input[3], input[4]);
                    break;
                }

                inputLine = Console.ReadLine();
                input     = inputLine.Split();

                var foodType = input[0];
                var quantity = int.Parse(input[1]);

                switch (foodType)
                {
                case nameof(Vegetable):
                    food = new Vegetable(quantity);
                    break;

                case nameof(Fruit):
                    food = new Fruit(quantity);
                    break;

                case nameof(Meat):
                    food = new Meat(quantity);
                    break;

                case nameof(Seeds):
                    food = new Seeds(quantity);
                    break;
                }

                Console.WriteLine(animal.ProduceSound());

                try
                {
                    animal.EatFood(food);
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                }

                animals.Add(animal);
            }

            animals.ForEach(a => Console.WriteLine(a));
        }
Beispiel #26
0
        static void Main(string[] args)
        {
            Animal animal = null;

            string[] tokens             = Console.ReadLine().Split(' ');
            string   animalType         = tokens[0];
            string   animalName         = tokens[1];
            double   animalWeight       = double.Parse(tokens[2]);
            string   animalLivingRegion = tokens[3];

            switch (animalType)
            {
            case "Cat":
                string catBreed = tokens[4];
                animal = new Cat(animalType, animalName, animalWeight, animalLivingRegion, catBreed);
                break;

            case "Tiger":
                animal = new Tiger(animalType, animalName, animalWeight, animalLivingRegion);
                break;

            case "Zebra":
                animal = new Zebra(animalType, animalName, animalWeight, animalLivingRegion);
                break;

            case "Mouse":
                animal = new Mouse(animalType, animalName, animalWeight, animalLivingRegion);
                break;

            default:
                break;
            }

            string[] foodTokens   = Console.ReadLine().Split(' ');
            string   foodType     = foodTokens[0];
            int      foodQuantity = int.Parse(foodTokens[1]);
            Food     food         = null;

            switch (foodType)
            {
            case "Vegetable":
                food = new Vegetable(foodQuantity);
                break;

            case "Meal":
                food = new Meat(foodQuantity);
                break;

            default:
                break;
            }
            try
            {
                animal.MakeSound();
                animal.Eat(food);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine(animal);
        }
Beispiel #27
0
        public static void Main()
        {
            string        command = string.Empty;
            List <Animal> animals = new List <Animal>();

            while ((command = Console.ReadLine()) != "End")
            {
                //TODO: try catch exeptions
                string[] args   = command.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                string   type   = args[0];
                string   name   = args[1];
                double   weight = double.Parse(args[2]);

                string[] foodInput   = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
                string   foodType    = foodInput[0];
                int      foodQuanity = int.Parse(foodInput[1]);

                //TODO: if food is null
                Food food = null;
                switch (foodType)
                {
                case "Vegetable":
                    food = new Vegetable(foodQuanity);
                    break;

                case "Fruit":
                    food = new Fruit(foodQuanity);
                    break;

                case "Meat":
                    food = new Meat(foodQuanity);
                    break;

                case "Seeds":
                    food = new Seeds(foodQuanity);
                    break;

                default:
                    break;
                }

                Animal animal = null;
                switch (type)
                {
                case "Owl":
                    double wingsSize = double.Parse(args[3]);
                    animal = new Owl(name, weight, wingsSize);
                    break;

                case "Hen":
                    wingsSize = double.Parse(args[3]);
                    animal    = new Hen(name, weight, wingsSize);
                    break;

                case "Mouse":
                    string livingRegion = args[3];
                    animal = new Mouse(name, weight, livingRegion);
                    break;

                case "Dog":
                    livingRegion = args[3];
                    animal       = new Dog(name, weight, livingRegion);
                    break;

                case "Cat":
                    livingRegion = args[3];
                    string breed = args[4];
                    animal = new Cat(name, weight, livingRegion, breed);
                    break;

                case "Tiger":
                    livingRegion = args[3];
                    breed        = args[4];
                    animal       = new Tiger(name, weight, livingRegion, breed);
                    break;
                }

                animal.Eat(food);
                Console.WriteLine();
                animals.Add(animal);
            }
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            var input = string.Empty;

            while ((input = Console.ReadLine()) != "End")
            {
                var animalInformation = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var foodInformation   = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                Animal currentAnimal = null;
                Food   currentFood   = null;

                var animalType   = animalInformation[0];
                var animalName   = animalInformation[1];
                var animalWeight = double.Parse(animalInformation[2]);
                var animalRegion = animalInformation[3];
                var animalBreed  = string.Empty;

                if (animalType == "Cat")
                {
                    animalBreed   = animalInformation[4];
                    currentAnimal = new Cat(animalName, animalType, animalWeight, animalRegion, animalBreed);
                }
                else
                {
                    switch (animalType)
                    {
                    case "Tiger":
                        currentAnimal = new Tiger(animalName, animalType, animalWeight, animalRegion);
                        break;

                    case "Zebra":
                        currentAnimal = new Zebra(animalName, animalType, animalWeight, animalRegion);
                        break;

                    case "Mouse":
                        currentAnimal = new Mouse(animalName, animalType, animalWeight, animalRegion);
                        break;
                    }
                }

                var foodType   = foodInformation[0];
                var foodAmount = int.Parse(foodInformation[1]);

                if (foodType == "Vegetable")
                {
                    currentFood = new Vegetable(foodAmount);
                }
                else if (foodType == "Meat")
                {
                    currentFood = new Meat(foodAmount);
                }

                Console.WriteLine(currentAnimal.MakeSound());

                try
                {
                    currentAnimal.Eat(currentFood);
                }
                catch (InvalidOperationException ioe)
                {
                    Console.WriteLine(ioe.Message);
                }

                Console.WriteLine(currentAnimal);
            }
        }
        static void Main(string[] args)
        {
            var input       = Console.ReadLine();
            int countOfRows = 0;

            var listOfAnimals = new List <Animal>();
            var result        = new List <Animal>();


            while (input != "End")
            {
                try
                {
                    var command = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

                    if (countOfRows % 2 == 0)
                    {
                        switch (command[0])
                        {
                        case "Owl":
                            Owl owl = new Owl(command[1], double.Parse(command[2]), double.Parse(command[3]));
                            listOfAnimals.Add(owl);
                            break;

                        case "Hen":
                            Hen hen = new Hen(command[1], double.Parse(command[2]), double.Parse(command[3]));
                            listOfAnimals.Add(hen);
                            break;

                        case "Cat":
                            Cat cat = new Cat(command[1], double.Parse(command[2]), command[3], command[4]);
                            listOfAnimals.Add(cat);
                            break;

                        case "Tiger":
                            Tiger tiger = new Tiger(command[1], double.Parse(command[2]), command[4], command[3]);
                            listOfAnimals.Add(tiger);
                            break;

                        case "Mouse":
                            Mouse mouse = new Mouse(command[1], double.Parse(command[2]), command[3]);
                            listOfAnimals.Add(mouse);
                            break;

                        case "Dog":
                            Dog dog = new Dog(command[1], double.Parse(command[2]), command[3]);
                            listOfAnimals.Add(dog);
                            break;

                        default:
                            throw new ArgumentException("Invalid Animal!");
                        }
                    }
                    else
                    {
                        var currentAnimal = listOfAnimals[listOfAnimals.Count - 1];
                        currentAnimal.ProduceSound();
                        switch (command[0])
                        {
                        case "Fruit":
                            Fruit fruit = new Fruit(int.Parse(command[1]));
                            if (currentAnimal.WhatCanEat.Contains(fruit.GetType().Name))
                            {
                                currentAnimal.Eat(fruit.Quantity);
                                result.Add(currentAnimal);
                            }
                            else
                            {
                                result.Add(currentAnimal);
                                throw new ArgumentException($"{currentAnimal.GetType().Name} does not eat {fruit.GetType().Name}!");
                            }
                            break;

                        case "Meat":
                            Meat meat = new Meat(int.Parse(command[1]));
                            if (currentAnimal.WhatCanEat.Contains(meat.GetType().Name))
                            {
                                currentAnimal.Eat(meat.Quantity);
                                result.Add(currentAnimal);
                            }
                            else
                            {
                                result.Add(currentAnimal);
                                throw new ArgumentException($"{currentAnimal.GetType().Name} does not eat {meat.GetType().Name}!");
                            }
                            break;

                        case "Vegetable":
                            Vegetable vegetable = new Vegetable(int.Parse(command[1]));
                            if (currentAnimal.WhatCanEat.Contains((vegetable.GetType().Name).ToString()))
                            {
                                currentAnimal.Eat(vegetable.Quantity);
                                result.Add(currentAnimal);
                            }
                            else
                            {
                                result.Add(currentAnimal);
                                throw new ArgumentException($"{currentAnimal.GetType().Name} does not eat {vegetable.GetType().Name}!");
                            }
                            break;

                        default:
                            throw new ArgumentException("Invalid Food!");
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                input = Console.ReadLine();
                countOfRows++;
            }
            foreach (var animal in result)
            {
                Console.WriteLine(animal.ToString());
            }
        }
        public static void Main(string[] args)
        {
            List <Animal> animals = new List <Animal>();

            string animalInfo = string.Empty;

            while ((animalInfo = Console.ReadLine()) != "End")
            {
                string[] info = animalInfo.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                Animal animal = null;

                string animalType = info[0];
                string animalName = info[1];
                double weight     = double.Parse(info[2]);

                if (animalType == "Cat" || animalType == "Tiger")
                {
                    string livingRegion = info[3];
                    string breed        = info[4];

                    if (animalType == "Cat")
                    {
                        animal = new Cat(animalName, weight, livingRegion, breed);
                    }

                    else
                    {
                        animal = new Tiger(animalName, weight, livingRegion, breed);
                    }
                }

                else if (animalType == "Owl" || animalType == "Hen")
                {
                    double wingSize = double.Parse(info[3]);

                    if (animalType == "Owl")
                    {
                        animal = new Owl(animalName, weight, wingSize);
                    }

                    else
                    {
                        animal = new Hen(animalName, weight, wingSize);
                    }
                }

                else if (animalType == "Mouse" || animalType == "Dog")
                {
                    string livingRegion = info[3];

                    if (animalType == "Mouse")
                    {
                        animal = new Mouse(animalName, weight, livingRegion);
                    }
                    else
                    {
                        animal = new Dog(animalName, weight, livingRegion);
                    }
                }

                animals.Add(animal);

                Console.WriteLine(animal.ProduceSound());

                string[] foodInfo = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

                string foodType = foodInfo[0];
                int    quantity = int.Parse(foodInfo[1]);

                Food food = null;

                if (foodType == "Vegetable")
                {
                    food = new Vegetable(quantity);
                }

                else if (foodType == "Fruit")
                {
                    food = new Fruit(quantity);
                }

                else if (foodType == "Meat")
                {
                    food = new Meat(quantity);
                }

                else if (foodType == "Seeds")
                {
                    food = new Seeds(quantity);
                }

                Type animalT = animal.GetType();

                if (animalT.Name == "Hen")
                {
                    animal.Weight    += 0.35 * quantity;
                    animal.FoodEaten += quantity;
                }

                else if (animalT.Name == "Mouse")
                {
                    if (foodType == "Fruit" || foodType == "Vegetable")
                    {
                        animal.Weight    += 0.10 * quantity;
                        animal.FoodEaten += quantity;
                    }

                    else
                    {
                        Console.WriteLine($"{animalT.Name} does not eat {foodType}!");
                    }
                }

                else if (animalT.Name == "Cat")
                {
                    if (foodType == "Meat" || foodType == "Vegetable")
                    {
                        animal.Weight    += 0.30 * quantity;
                        animal.FoodEaten += quantity;
                    }

                    else
                    {
                        Console.WriteLine($"{animalT.Name} does not eat {foodType}!");
                    }
                }

                else if (animalT.Name == "Tiger" || animalT.Name == "Dog" || animalT.Name == "Owl")
                {
                    if (foodType == "Meat")
                    {
                        if (animalT.Name == "Tiger")
                        {
                            animal.Weight += 1.00 * quantity;
                        }

                        else if (animalT.Name == "Dog")
                        {
                            animal.Weight += 0.40 * quantity;
                        }

                        else if (animalT.Name == "Owl")
                        {
                            animal.Weight += 0.25 * quantity;
                        }

                        animal.FoodEaten += quantity;
                    }

                    else
                    {
                        Console.WriteLine($"{animalT.Name} does not eat {foodType}!");
                    }
                }
            }

            foreach (var animal in animals)
            {
                Console.WriteLine(animal.ToString());
            }
        }