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

            switch (tokens[0])
            {
            case "Hen":
                Animal newHen = new Hen(tokens[1], double.Parse(tokens[2]), double.Parse(tokens[3]));
                return(newHen);

            case "Owl":
                Animal newOwl = new Owl(tokens[1], double.Parse(tokens[2]), double.Parse(tokens[3]));
                return(newOwl);

            case "Cat":
                Animal newCat = new Cat(tokens[1], double.Parse(tokens[2]), tokens[3], tokens[4]);
                return(newCat);

            case "Tiger":
                Animal newTiger = new Tiger(tokens[1], double.Parse(tokens[2]), tokens[3], tokens[4]);
                return(newTiger);

            case "Dog":
                Animal newDog = new Dog(tokens[1], double.Parse(tokens[2]), tokens[3]);
                return(newDog);

            case "Mouse":
                Animal newMouse = new Mouse(tokens[1], double.Parse(tokens[2]), tokens[3]);
                return(newMouse);

            default:
                return(null);
            }
        }
Beispiel #2
0
        public static Animal CreateAnimal(string[] args)
        {
            switch (args[0])
            {
            case "Hen":
                Hen hen = new Hen(args[1], double.Parse(args[2]), double.Parse(args[3]));
                return(hen);

            case "Owl":
                Owl owl = new Owl(args[1], double.Parse(args[2]), double.Parse(args[3]));
                return(owl);

            case "Dog":
                Dog dog = new Dog(args[1], double.Parse(args[2]), args[3]);
                return(dog);

            case "Mouse":
                Mouse mouse = new Mouse(args[1], double.Parse(args[2]), args[3]);
                return(mouse);

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

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

            default:
                return(null);
            }
        }
Beispiel #3
0
        private static Animal CreateAnimal(string[] animalData)
        {
            Animal animalToReturn = null;
            var    type           = animalData[0];

            if (type == nameof(Owl) || type == nameof(Hen))
            {
                var name     = animalData[1];
                var weight   = double.Parse(animalData[2]);
                var wingSize = double.Parse(animalData[3]);

                if (type == nameof(Owl))
                {
                    animalToReturn = new Owl(name, weight, wingSize);
                }

                else
                {
                    animalToReturn = new Hen(name, weight, wingSize);
                }
            }

            else if (type == nameof(Mouse) || type == nameof(Dog))
            {
                var name         = animalData[1];
                var weight       = double.Parse(animalData[2]);
                var livingRegion = animalData[3];

                if (type == nameof(Mouse))
                {
                    animalToReturn = new Mouse(name, weight, livingRegion);
                }

                else
                {
                    animalToReturn = new Dog(name, weight, livingRegion);
                }
            }

            else if (type == nameof(Cat) || type == nameof(Tiger))
            {
                var name         = animalData[1];
                var weight       = double.Parse(animalData[2]);
                var livingRegion = animalData[3];
                var breed        = animalData[4];

                if (type == nameof(Cat))
                {
                    animalToReturn = new Cat(name, weight, livingRegion, breed);
                }

                else
                {
                    animalToReturn = new Tiger(name, weight, livingRegion, breed);
                }
            }

            return(animalToReturn);
        }
        public static Animal CreateAnimal(string[] animalInfo)
        {
            Animal animal = null;
            string type   = animalInfo[0];

            if (type == "Owl")
            {
                string name     = animalInfo[1];
                double weight   = double.Parse(animalInfo[2]);
                double wingSize = double.Parse(animalInfo[3]);

                animal = new Owl(name, weight, 0, wingSize);
            }
            else if (type == "Hen")
            {
                string name     = animalInfo[1];
                double weight   = double.Parse(animalInfo[2]);
                double wingSize = double.Parse(animalInfo[3]);

                animal = new Hen(name, weight, 0, wingSize);
            }
            else if (type == "Mouse")
            {
                string name         = animalInfo[1];
                double weight       = double.Parse(animalInfo[2]);
                string livingRegion = animalInfo[3];

                animal = new Mouse(name, weight, 0, livingRegion);
            }
            else if (type == "Dog")
            {
                string name         = animalInfo[1];
                double weight       = double.Parse(animalInfo[2]);
                string livingRegion = animalInfo[3];

                animal = new Dog(name, weight, 0, livingRegion);
            }
            else if (type == "Cat")
            {
                string name         = animalInfo[1];
                double weight       = double.Parse(animalInfo[2]);
                string livingRegion = animalInfo[3];
                string breed        = animalInfo[4];

                animal = new Cat(name, weight, 0, livingRegion, breed);
            }
            else if (type == "Tiger")
            {
                string name         = animalInfo[1];
                double weight       = double.Parse(animalInfo[2]);
                string livingRegion = animalInfo[3];
                string breed        = animalInfo[4];

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

            return(animal);
        }
        private Animal GetAnimal(string input)
        {
            Animal currentAnimal = null;

            List <string> inputInfo = input.Split().ToList();

            string type = inputInfo[0];

            string name = inputInfo[1];

            double weight = double.Parse(inputInfo[2]);

            if (type == "Cat" || type == "Tiger")
            {
                string livingRegion = inputInfo[3];

                string breed = inputInfo[4];

                if (type == "Cat")
                {
                    currentAnimal = new Cat(name, weight, livingRegion, breed);
                }
                else if (type == "Tiger")
                {
                    currentAnimal = new Tiger(name, weight, livingRegion, breed);
                }
            }
            else if (type == "Hen" || type == "Owl")
            {
                double wingSize = double.Parse(inputInfo[3]);

                if (type == "Hen")
                {
                    currentAnimal = new Hen(name, weight, wingSize);
                }
                else if (type == "Owl")
                {
                    currentAnimal = new Owl(name, weight, wingSize);
                }
            }
            else if (type == "Mouse" || type == "Dog")
            {
                string livingRegion = inputInfo[3];

                if (type == "Mouse")
                {
                    currentAnimal = new Mouse(name, weight, livingRegion);
                }
                else if (type == "Dog")
                {
                    currentAnimal = new Dog(name, weight, livingRegion);
                }
            }

            return(currentAnimal);
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            string[]      info;
            List <Animal> animals = new List <Animal>();

            while (true)
            {
                info = Console.ReadLine().Split(' ');

                if (info[0] == "End")
                {
                    break;
                }
                string[] food   = Console.ReadLine().Split(' ');
                Animal   animal = null;
                switch (info[0])
                {
                case "Cat":
                    animal = new Cat(info[1], Convert.ToDouble(info[2]), info[3], info[4], Convert.ToInt32(food[1]));
                    break;

                case "Tiger":
                    animal = new Tiger(info[1], Convert.ToDouble(info[2]), info[3], info[4], Convert.ToInt32(food[1]));
                    break;

                case "Hen":
                    Hen hen = new Hen(info[1], Convert.ToDouble(info[2]), Convert.ToDouble(info[3]), Convert.ToInt32(food[1]));
                    break;

                case "Owl":
                    Owl owl = new Owl(info[1], Convert.ToDouble(info[2]), Convert.ToDouble(info[3]), Convert.ToInt32(food[1]));
                    break;

                case "Mouse":
                    Mouse mouse = new Mouse(info[1], Convert.ToDouble(info[2]), info[3], Convert.ToInt32(food[1]));
                    break;

                case "Dog":
                    Dog dog = new Dog(info[1], Convert.ToDouble(info[2]), info[3], Convert.ToInt32(food[1]));;
                    break;

                default:
                    Console.WriteLine($"{info[0]} does not exist.");
                    break;
                }
                animal.Talk();
                animal.Eat(food[0], food[1]);
                animals.Add(animal);
            }

            foreach (var animal in animals)
            {
                Console.WriteLine(animal.ToString());
            }
        }
Beispiel #7
0
        private Animal CreateAnimal(string command)
        {
            string[] animalArgs = command
                                  .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                                  .ToArray();

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

            Animal animal = null;

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

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

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

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

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

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

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

            this.animals.Add(animal);

            return(animal);
        }
Beispiel #8
0
        public static Animal CreateAnimal(string[] line)
        {
            Animal animal = null;

            string animalType = line[0];               // вид
            string name       = line[1];               //име
            double weight     = double.Parse(line[2]); //тегло

            if (animalType == nameof(Cat))
            {
                string livingRegion = line[3];
                string breed        = line[4];

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

            else if (animalType == nameof(Tiger))
            {
                string livingRegion = line[3];
                string breed        = line[4];

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

            else if (animalType == nameof(Dog))
            {
                string livingRegion = line[3];
                animal = new Dog(name, weight, livingRegion);
            }

            else if (animalType == nameof(Mouse))
            {
                string livingRegion = line[3];
                animal = new Mouse(name, weight, livingRegion);
            }

            else if (animalType == nameof(Hen))
            {
                double wingSize = double.Parse(line[3]);
                animal = new Hen(name, weight, wingSize);
            }

            else if (animalType == nameof(Owl))
            {
                double wingSize = double.Parse(line[3]);
                animal = new Owl(name, weight, wingSize);
            }

            // protected Cat(string name, double weight, string breed, string livingRegion)
            // Felines - "{Type} {Name} {Weight} {LivingRegion} {Breed}";

            return(animal);
        }
Beispiel #9
0
        public Animal CreateAnimal(string typeStr, string name, double weight, string[] args)
        {
            Animal animal = null;

            if (args.Length == 1)
            {
                bool isBird = double.TryParse(args[0], out double wingSize);
                if (isBird)
                {
                    if (typeStr == "Owl")
                    {
                        animal = new Owl(name, weight, wingSize);
                        animal.ProduceSound();
                    }
                    else
                    {
                        animal = new Hen(name, weight, wingSize);
                        animal.ProduceSound();
                    }
                }
                else
                {
                    string livingRegion = args[0];
                    if (typeStr == "Mouse")
                    {
                        animal = new Mouse(name, weight, livingRegion);
                        animal.ProduceSound();
                    }
                    else
                    {
                        animal = new Dog(name, weight, livingRegion);
                        animal.ProduceSound();
                    }
                }
            }
            else
            {
                string livingRegion = args[0];
                string breed        = args[1];
                if (typeStr == "Cat")
                {
                    animal = new Cat(name, weight, livingRegion, breed);
                    animal.ProduceSound();
                }
                else
                {
                    animal = new Tiger(name, weight, livingRegion, breed);
                    animal.ProduceSound();
                }
            }
            return(animal);
        }
Beispiel #10
0
        private static Animal CreateAnimal(string[] parts)
        {
            string type = parts[0];

            Animal animal = null;

            string name   = parts[1];
            double weight = double.Parse(parts[2]);

            if (type == nameof(Cat))
            {
                string livingRegion = parts[3];
                string breed        = parts[4];

                animal = new Cat(name, weight, livingRegion, breed);
            }
            else if (type == nameof(Tiger))
            {
                string livingRegion = parts[3];
                string breed        = parts[4];

                animal = new Tiger(name, weight, livingRegion, breed);
            }
            else if (type == nameof(Owl))
            {
                double wingSize = double.Parse(parts[3]);

                animal = new Owl(name, weight, wingSize);
            }
            else if (type == nameof(Hen))
            {
                double wingSize = double.Parse(parts[3]);

                animal = new Hen(name, weight, wingSize);
            }
            else if (type == nameof(Dog))
            {
                string livingRegion = parts[3];

                animal = new Dog(name, weight, livingRegion);
            }
            else if (type == nameof(Mouse))
            {
                string livingRegion = parts[3];

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

            return(animal);
        }
Beispiel #11
0
        private static Animal CreateAnimal(string[] parts)
        {
            Animal animal = null;

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

            if (type == "Hen")
            {
                double wingSize = double.Parse(parts[3]);

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

                animal = new Owl(name, weight, wingSize);
            }
            else if (type == "Mouse")
            {
                string livingRegion = parts[3];

                animal = new Mouse(name, weight, livingRegion);
            }
            else if (type == "Dog")
            {
                string livingRegion = parts[3];

                animal = new Dog(name, weight, livingRegion);
            }
            else if (type == "Cat")
            {
                string livingRegion = parts[3];
                string breed        = parts[4];

                animal = new Cat(name, weight, livingRegion, breed);
            }
            else if (type == "Tiger")
            {
                string livingRegion = parts[3];
                string breed        = parts[4];

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

            return(animal);
        }
Beispiel #12
0
        private static Animal AnimalGenerator(string[] commands)
        {
            //Birds – "{AnimalType} [{AnimalName}, {WingSize}, {AnimalWeight}, {FoodEaten}]"
            //Felines – "{AnimalType} [{AnimalName}, {Breed}, {AnimalWeight}, {AnimalLivingRegion}, {FoodEaten}]"
            //Mice and Dogs – "{AnimalType} [{AnimalName}, {AnimalWeight}, {AnimalLivingRegion}, {FoodEaten}]"

            Animal current = null;

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

            if (type == nameof(Dog))
            {
                string region = commands[3];
                current = new Dog(name, weight, region);
            }
            else if (type == nameof(Mouse))
            {
                string region = commands[3];
                current = new Mouse(name, weight, region);
            }
            else if (type == nameof(Owl))
            {
                double wingSize = double.Parse(commands[3]);
                current = new Owl(name, weight, wingSize);
            }
            else if (type == nameof(Hen))
            {
                double wingSize = double.Parse(commands[3]);
                current = new Hen(name, weight, wingSize);
            }
            else if (type == nameof(Cat))
            {
                string livingRegion = commands[3];
                string breed        = commands[4];
                current = new Cat(name, weight, livingRegion, breed);
            }
            else if (type == nameof(Tiger))
            {
                string livingRegion = commands[3];
                string breed        = commands[4];
                current = new Tiger(name, weight, livingRegion, breed);
            }


            return(current);
        }
Beispiel #13
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 #14
0
        public static IAnimal CreateAnimal(string[] inputArr)
        {
            IAnimal animal = null;

            switch (inputArr[0].ToLower())
            {
            case "tiger":
            {
                animal = new Tiger(inputArr[1], double.Parse(inputArr[2]), inputArr[3], inputArr[4]);
            }
            break;

            case "owl":
            {
                animal = new Owl(inputArr[1], double.Parse(inputArr[2]), double.Parse(inputArr[3]));
            }
            break;

            case "hen":
            {
                animal = new Hen(inputArr[1], double.Parse(inputArr[2]), double.Parse(inputArr[3]));
            }
            break;

            case "mouse":
            {
                animal = new Mouse(inputArr[1], double.Parse(inputArr[2]), inputArr[3]);
            }
            break;

            case "dog":
            {
                animal = new Dog(inputArr[1], double.Parse(inputArr[2]), inputArr[3]);
            }
            break;

            case "cat":
            {
                animal = new Cat(inputArr[1], double.Parse(inputArr[2]), inputArr[3], inputArr[4]);
            }
            break;
            }

            return(animal);
        }
Beispiel #15
0
        private static Animal ReadAnimal(string str)
        {
            var data = str.Split();

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

            Animal animal = null;

            if (type == "Owl")
            {
                double wingSize = double.Parse(data[3]);
                animal = new Owl(name, weight, wingSize);
            }
            else if (type == "Hen")
            {
                double wingSize = double.Parse(data[3]);
                animal = new Hen(name, weight, wingSize);
            }
            else if (type == "Cat")
            {
                string livingRegion = data[3];
                string breed        = data[4];
                animal = new Cat(name, weight, livingRegion, breed);
            }
            else if (type == "Tiger")
            {
                string livingRegion = data[3];
                string breed        = data[4];
                animal = new Tiger(name, weight, livingRegion, breed);
            }
            else if (type == "Mouse")
            {
                string livingRegion = data[3];
                animal = new Mouse(name, weight, livingRegion);
            }
            else if (type == "Dog")
            {
                string livingRegion = data[3];
                animal = new Dog(name, weight, livingRegion);
            }

            return(animal);
        }
Beispiel #16
0
        private static List <Animal> InitAnimals(string command)
        {
            List <Animal> animals = new List <Animal>();

            try
            {
                string[] animalData = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                string   animalType = animalData[0];
                string   animalName = animalData[1];
                double.TryParse(animalData[2], out double animalWeight);
                string livingRegion = animalData[3];

                switch (animalType)
                {
                case "Cat":
                    string breed = animalData[4];
                    Animal cat   = new Cat(animalType, animalName, animalWeight, livingRegion, breed);
                    animals.Add(cat);
                    break;

                case "Zebra":
                    Animal zebra = new Zebra(animalType, animalName, animalWeight, livingRegion);
                    animals.Add(zebra);
                    break;

                case "Mouse":
                    Animal mouse = new Mouse(animalType, animalName, animalWeight, livingRegion);
                    animals.Add(mouse);
                    break;

                case "Tiger":
                    Animal tiger = new Tiger(animalType, animalName, animalWeight, livingRegion);
                    animals.Add(tiger);
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(animals);
        }
Beispiel #17
0
        private static Animal CreateAnimal(string[] animalInput)
        {
            Animal animal = null;
            var    type   = animalInput[0];
            var    name   = animalInput[1];
            var    weight = double.Parse(animalInput[2]);

            if (type == nameof(Owl))
            {
                var wingSize = double.Parse(animalInput[3]);
                animal = new Owl(name, weight, 0, wingSize);
            }
            else if (type == nameof(Hen))
            {
                var wingSize = double.Parse(animalInput[3]);
                animal = new Hen(name, weight, 0, wingSize);
            }
            else if (type == nameof(Dog))
            {
                var region = animalInput[3];
                animal = new Dog(name, weight, 0, region);
            }
            else if (type == nameof(Mouse))
            {
                var region = animalInput[3];
                animal = new Mouse(name, weight, 0, region);
            }
            else if (type == nameof(Cat))
            {
                var region = animalInput[3];
                var breed  = animalInput[4];
                animal = new Cat(name, weight, 0, region, breed);
            }
            else if (type == nameof(Tiger))
            {
                var region = animalInput[3];
                var breed  = animalInput[4];
                animal = new Tiger(name, weight, 0, region, breed);
            }

            return(animal);
        }
Beispiel #18
0
        public static Animal CreateAnimal(string[] animalInfo)
        {
            Animal animal;

            switch (animalInfo[0])
            {
            case "Cat":
                animal = new Cat(animalInfo[1], double.Parse(animalInfo[2]), animalInfo[3], animalInfo[4]);
                break;

            case "Tiger":
                animal = new Tiger(animalInfo[1], double.Parse(animalInfo[2]), animalInfo[3], animalInfo[4]);
                break;

            case "Owl":
                animal = new Owl(animalInfo[1], double.Parse(animalInfo[2]), double.Parse(animalInfo[3]));
                break;

            case "Hen":
                animal = new Hen(animalInfo[1], double.Parse(animalInfo[2]), double.Parse(animalInfo[3]));
                break;

            case "Mouse":
                animal = new Mouse(animalInfo[1], double.Parse(animalInfo[2]), animalInfo[3]);
                break;

            case "Dog":
                animal = new Dog(animalInfo[1], double.Parse(animalInfo[2]), animalInfo[3]);
                break;

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

            return(animal);
        }
Beispiel #19
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 #20
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 #21
0
        public static void Main(string[] args)
        {
            var input = Console.ReadLine();

            var list = new List <Animal>();

            while (input != "End")
            {
                var line = input.Split();

                if (line[0] == "Cat")
                {
                    Animal cat = new Cat(line[1], double.Parse(line[2]), 0, line[3], line[4]);

                    var food = Console.ReadLine().Split();

                    Console.WriteLine(cat.ProduceSound());

                    if (food[0] == "Vegetable" || food[0] == "Meat")
                    {
                        cat.FoodEaten += int.Parse(food[1]);
                        cat.Weight    += 0.3 * int.Parse(food[1]);
                    }
                    else
                    {
                        Console.WriteLine($"Cat does not eat {food[0]}!");
                    }

                    list.Add(cat);
                }
                if (line[0] == "Tiger")
                {
                    Animal tiger = new Tiger(line[1], double.Parse(line[2]), 0, line[3], line[4]);

                    var food = Console.ReadLine().Split();

                    Console.WriteLine(tiger.ProduceSound());

                    if (food[0] == "Meat")
                    {
                        tiger.FoodEaten += int.Parse(food[1]);
                        tiger.Weight    += 1 * int.Parse(food[1]);
                    }
                    else
                    {
                        Console.WriteLine($"Tiger does not eat {food[0]}!");
                    }

                    list.Add(tiger);
                }
                if (line[0] == "Dog")
                {
                    Animal dog = new Dog(line[1], double.Parse(line[2]), 0, line[3]);

                    var food = Console.ReadLine().Split();

                    Console.WriteLine(dog.ProduceSound());

                    if (food[0] == "Meat")
                    {
                        dog.FoodEaten += int.Parse(food[1]);
                        dog.Weight    += 0.40 * int.Parse(food[1]);
                    }
                    else
                    {
                        Console.WriteLine($"Dog does not eat {food[0]}!");
                    }

                    list.Add(dog);
                }
                if (line[0] == "Owl")
                {
                    Animal owl = new Owl(line[1], double.Parse(line[2]), 0, double.Parse(line[3]));

                    var food = Console.ReadLine().Split();

                    Console.WriteLine(owl.ProduceSound());

                    if (food[0] == "Meat")
                    {
                        owl.FoodEaten += int.Parse(food[1]);
                        owl.Weight    += 0.25 * int.Parse(food[1]);
                    }
                    else
                    {
                        Console.WriteLine($"Owl does not eat {food[0]}!");
                    }

                    list.Add(owl);
                }
                if (line[0] == "Mouse")
                {
                    Animal mouse = new Mouse(line[1], double.Parse(line[2]), 0, line[3]);

                    var food = Console.ReadLine().Split();

                    Console.WriteLine(mouse.ProduceSound());

                    if (food[0] == "Fruit" || food[0] == "Vegetable")
                    {
                        mouse.FoodEaten += int.Parse(food[1]);
                        mouse.Weight    += 0.10 * int.Parse(food[1]);
                    }
                    else
                    {
                        Console.WriteLine($"Mouse does not eat {food[0]}!");
                    }

                    list.Add(mouse);
                }
                if (line[0] == "Hen")
                {
                    Animal hen = new Hen(line[1], double.Parse(line[2]), 0, double.Parse(line[3]));

                    var food = Console.ReadLine().Split();

                    Console.WriteLine(hen.ProduceSound());

                    hen.FoodEaten += int.Parse(food[1]);
                    hen.Weight    += 0.35 * int.Parse(food[1]);
                    list.Add(hen);
                }

                input = Console.ReadLine();
            }

            foreach (var item in list)
            {
                Console.WriteLine(item);
            }
        }
Beispiel #22
0
        public void Run()
        {
            while (true)
            {
                string input = Console.ReadLine();

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

                string[] inputArgs = input
                    .Split();

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

                IAnimal currentAnimal = null;

                if(animalType == "Owl")
                {
                    double wingSize = double.Parse(inputArgs[3]);
                    currentAnimal = new Owl(name, weight, wingSize);
                }
                else if(animalType == "Hen")
                {
                    double wingSize = double.Parse(inputArgs[3]);
                    currentAnimal = new Hen(name, weight, wingSize);
                }
                else if(animalType == "Mouse")
                {
                    string livingRegion = inputArgs[3];
                    currentAnimal = new Mouse(name, weight, livingRegion);
                }
                else if(animalType == "Dog")
                {
                    string livingRegion = inputArgs[3];
                    currentAnimal = new Dog(name, weight, livingRegion);
                }
                else if(animalType == "Cat")
                {
                    string livingRegion = inputArgs[3];
                    string breed = inputArgs[4];
                    currentAnimal = new Cat(name, weight, livingRegion, breed);
                }
                else if(animalType == "Tiger")
                {
                    string livingRegion = inputArgs[3];
                    string breed = inputArgs[4];
                    currentAnimal = new Tiger(name, weight, livingRegion, breed);
                }

                animals.Add(currentAnimal);

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

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

                Console.WriteLine(currentAnimal.ProduceSound());

                if (!currentAnimal.CurrentTypeEatFood.Any(x => x == Enum.Parse<TypeFood>(foodType)))
                {
                    Console.WriteLine($"{currentAnimal.GetType().Name} does not eat {foodType}!");
                }
                else
                {
                    currentAnimal.AddWeight(quantity);
                }
            }

            foreach (var item in animals)
            {
                Console.WriteLine(item);
            }
        }
Beispiel #23
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 #24
0
        static void Main(string[] args)
        {
            var animals = new List <Animal>();

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

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

                var animalInfo = command.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                var foodInfo = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
                var foodType = foodInfo[0];
                var quantity = int.Parse(foodInfo[1]);

                if (animalInfo[0] == "Owl")
                {
                    var name     = animalInfo[1];
                    var weight   = double.Parse(animalInfo[2]);
                    var wingSize = double.Parse(animalInfo[3]);

                    var animal = new Owl(name, weight, wingSize);
                    animal.ProduceSound();
                    animal.Eat(foodType, quantity);

                    animals.Add(animal);
                }

                else if (animalInfo[0] == "Hen")
                {
                    var name     = animalInfo[1];
                    var weight   = double.Parse(animalInfo[2]);
                    var wingSize = double.Parse(animalInfo[3]);

                    var animal = new Hen(name, weight, wingSize);
                    animal.ProduceSound();
                    animal.Eat(foodType, quantity);

                    animals.Add(animal);
                }

                else if (animalInfo[0] == "Mouse")
                {
                    var name         = animalInfo[1];
                    var weight       = double.Parse(animalInfo[2]);
                    var livingRegion = animalInfo[3];

                    var animal = new Mouse(name, weight, livingRegion);
                    animal.ProduceSound();
                    animal.Eat(foodType, quantity);

                    animals.Add(animal);
                }

                else if (animalInfo[0] == "Dog")
                {
                    var name         = animalInfo[1];
                    var weight       = double.Parse(animalInfo[2]);
                    var livingRegion = animalInfo[3];

                    var animal = new Dog(name, weight, livingRegion);
                    animal.ProduceSound();
                    animal.Eat(foodType, quantity);

                    animals.Add(animal);
                }

                else if (animalInfo[0] == "Cat")
                {
                    var name         = animalInfo[1];
                    var weight       = double.Parse(animalInfo[2]);
                    var livingRegion = animalInfo[3];
                    var breed        = animalInfo[4];

                    var animal = new Cat(name, weight, livingRegion, breed);
                    animal.ProduceSound();
                    animal.Eat(foodType, quantity);

                    animals.Add(animal);
                }

                else if (animalInfo[0] == "Tiger")
                {
                    var name         = animalInfo[1];
                    var weight       = double.Parse(animalInfo[2]);
                    var livingRegion = animalInfo[3];
                    var breed        = animalInfo[4];

                    var animal = new Tiger(name, weight, livingRegion, breed);
                    animal.ProduceSound();
                    animal.Eat(foodType, quantity);

                    animals.Add(animal);
                }
            }

            foreach (var animal in animals)
            {
                Console.WriteLine(animal);
            }
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            var listAnimals = new List <Animal>();
            var animalInput = Console.ReadLine().Split();

            while (animalInput[0] != "End")
            {
                var type      = animalInput[0];
                var name      = animalInput[1];
                var weight    = double.Parse(animalInput[2]);
                var food      = Console.ReadLine().Split();
                var foodType  = food[0];
                var foodCount = int.Parse(food[1]);
                if (animalInput.Count() == 4)
                {
                    if (double.TryParse(animalInput[3], out double wingSize))
                    {
                        if (type == "Hen")
                        {
                            var hen = new Hen(name, weight, wingSize);
                            Console.WriteLine(hen.MakeSound());
                            hen.EatFood(foodCount, hen.Multiplier);
                            listAnimals.Add(hen);
                        }
                        else
                        {
                            var owl = new Owl(name, weight, wingSize);
                            Console.WriteLine(owl.MakeSound());
                            if (foodType == "Meat")
                            {
                                owl.EatFood(foodCount, owl.Multiplier);
                            }
                            else
                            {
                                Console.WriteLine(owl.AnimalDoesntEat(foodType));
                            }
                            listAnimals.Add(owl);
                        }
                    }
                    else
                    {
                        var region = animalInput[3];
                        if (type == "Dog")
                        {
                            var dog = new Dog(name, weight, region);
                            Console.WriteLine(dog.MakeSound());
                            if (foodType == "Meat")
                            {
                                dog.EatFood(foodCount, dog.Multiplier);
                            }
                            else
                            {
                                Console.WriteLine(dog.AnimalDoesntEat(foodType));
                            }
                            listAnimals.Add(dog);
                        }
                        else
                        {
                            var mouse = new Mouse(name, weight, region);
                            Console.WriteLine(mouse.MakeSound());
                            if (foodType == "Vegetable" || foodType == "Fruit")
                            {
                                mouse.EatFood(foodCount, mouse.Multiplier);
                            }
                            else
                            {
                                Console.WriteLine(mouse.AnimalDoesntEat(foodType));
                            }
                            listAnimals.Add(mouse);
                        }
                    }
                }
                else
                {
                    var region = animalInput[3];
                    var breed  = animalInput[4];
                    if (type == "Cat")
                    {
                        var cat = new Cat(name, weight, region, breed);
                        Console.WriteLine(cat.MakeSound());
                        if (foodType == "Meat" || foodType == "Vegetable")
                        {
                            cat.EatFood(foodCount, cat.Multiplier);
                        }
                        else
                        {
                            Console.WriteLine(cat.AnimalDoesntEat(foodType));
                        }
                        listAnimals.Add(cat);
                    }
                    else
                    {
                        var tiger = new Tiger(name, weight, region, breed);
                        Console.WriteLine(tiger.MakeSound());
                        if (foodType == "Meat")
                        {
                            tiger.EatFood(foodCount, tiger.Multiplier);
                        }
                        else
                        {
                            Console.WriteLine(tiger.AnimalDoesntEat(foodType));
                        }
                        listAnimals.Add(tiger);
                    }
                }
                animalInput = Console.ReadLine().Split();
            }

            foreach (var item in listAnimals)
            {
                Console.WriteLine(item.ToString());
            }
        }
        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 #27
0
        public void Run()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (input == "End")
                {
                    break;
                }

                string[] tokens     = input.Split();
                string   typeAnimal = tokens[0];

                if (typeAnimal == "Cat")
                {
                    Animal   cat      = new Cat(tokens[1], double.Parse(tokens[2]), tokens[3], tokens[4]);
                    string[] food     = Console.ReadLine().Split();
                    string   typeFood = food[0];
                    cat.Sound();
                    if (typeFood.ToLower() == "vegetable" || typeFood.ToLower() == "fruit")
                    {
                        cat.Eat(int.Parse(food[1]));
                    }
                    else
                    {
                        Console.WriteLine($"Cat does not eat {typeFood}");
                    }
                    animals.Add(cat);
                }
                else if (typeAnimal == "Dog")
                {
                    Animal   dog      = new Dog(tokens[1], double.Parse(tokens[2]), tokens[3]);
                    string[] food     = Console.ReadLine().Split();
                    string   typeFood = food[0];
                    dog.Sound();
                    if (typeFood.ToLower() == "meat")
                    {
                        dog.Eat(int.Parse(food[1]));
                    }
                    else
                    {
                        Console.WriteLine($"Dog does not eat {typeFood}");
                    }
                    animals.Add(dog);
                }
                else if (typeAnimal == "Tiger")
                {
                    Animal   tiger    = new Tiger(tokens[1], double.Parse(tokens[2]), tokens[3], tokens[4]);
                    string[] food     = Console.ReadLine().Split();
                    string   typeFood = food[0];
                    tiger.Sound();
                    if (typeFood.ToLower() == "meat")
                    {
                        tiger.Eat(int.Parse(food[1]));
                    }
                    else
                    {
                        Console.WriteLine($"Tiger does not eat {typeFood}");
                    }
                    animals.Add(tiger);
                }
                else if (typeAnimal == "Mouse")
                {
                    Animal   mouse    = new Mouse(tokens[1], double.Parse(tokens[2]), tokens[3]);
                    string[] food     = Console.ReadLine().Split();
                    string   typeFood = food[0];
                    mouse.Sound();
                    if (typeFood.ToLower() == "vegetable" || typeFood.ToLower() == "fruit")
                    {
                        mouse.Eat(int.Parse(food[1]));
                    }
                    else
                    {
                        Console.WriteLine($"Mouse does not eat {typeFood}");
                    }
                    animals.Add(mouse);
                }
                else if (typeAnimal == "Owl")
                {
                    Animal   owl      = new Owl(tokens[1], double.Parse(tokens[2]), double.Parse(tokens[3]));
                    string[] food     = Console.ReadLine().Split();
                    string   typeFood = food[0];
                    owl.Sound();
                    if (typeFood.ToLower() == "meat")
                    {
                        owl.Eat(int.Parse(food[1]));
                    }
                    else
                    {
                        Console.WriteLine($"Mouse does not eat {typeFood}");
                    }
                    animals.Add(owl);
                }
                else if (typeAnimal == "Hen")
                {
                    Animal   hen      = new Hen(tokens[1], double.Parse(tokens[2]), double.Parse(tokens[3]));
                    string[] food     = Console.ReadLine().Split();
                    string   typeFood = food[0];
                    hen.Sound();
                    if (typeFood.ToLower() == "meat")
                    {
                        hen.Eat(int.Parse(food[1]));
                    }
                    else
                    {
                        Console.WriteLine($"Mouse does not eat {typeFood}");
                    }
                    animals.Add(hen);
                }
            }
            foreach (var animal in animals)
            {
                Console.WriteLine(animal);
            }
        }
Beispiel #28
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);
            }
        }
        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());
            }
        }
        static void Main(string[] args)
        {
            string         input   = String.Empty;
            List <IAnimal> animals = new List <IAnimal>();

            while ((input = Console.ReadLine()) != "End")
            {
                var inputTokens = input.Split();


                //ParseAnimal start
                var     animalType   = inputTokens[0];
                var     animalName   = inputTokens[1];
                var     animalWeight = double.Parse(inputTokens[2]);
                double  wingSize     = 0;
                string  livingRegion = String.Empty;
                string  breed        = String.Empty;
                IAnimal animal       = null;

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

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

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

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

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

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

                //ParseFood start
                var foodTokens   = Console.ReadLine().Split();
                var foodType     = foodTokens[0];
                var foodQuantity = int.Parse(foodTokens[1]);

                animal.ProduceSound();
                animal.Eat(animal, foodType, foodQuantity);

                //ParseFood end
            }
            foreach (var animal in animals)
            {
                Console.WriteLine(animal);
            }
        }