Example #1
0
        static void Main(string[] args)
        {
            string       input  = Console.ReadLine();
            List <Dog>   dogs   = new List <Dog>();
            List <Cat>   cats   = new List <Cat>();
            List <Snake> snakes = new List <Snake>();

            while (input != "I'm your Huckleberry")
            {
                string[] tokens = input.Split(' ');

                if (tokens[0] == "Dog")
                {
                    Dog dog = Dog.ReadDog(input);
                    dogs.Add(dog);
                }
                else if (tokens[0] == "Cat")
                {
                    Cat cat = Cat.ReadCat(input);
                    cats.Add(cat);
                }
                else if (tokens[0] == "Snake")
                {
                    Snake snake = Snake.ReadSnake(input);
                    snakes.Add(snake);
                }
                else
                {
                    if (dogs.Select(d => d.Name).Contains(tokens[1]))
                    {
                        Console.WriteLine(Dog.Sound);
                    }
                    else if (cats.Select(c => c.Name).Contains(tokens[1]))
                    {
                        Console.WriteLine(Cat.Sound);
                    }
                    else
                    {
                        Console.WriteLine(Snake.Sound);
                    }
                }

                input = Console.ReadLine();
            }

            foreach (var item in dogs)
            {
                Console.WriteLine($"Dog: {item.Name}, Age: {item.Age}, Number Of Legs: {item.NumberOfLegs}");
            }
            foreach (var item in cats)
            {
                Console.WriteLine($"Cat: {item.Name}, Age: {item.Age}, IQ: {item.IQ}");
            }
            foreach (var item in snakes)
            {
                Console.WriteLine($"Snake: {item.Name}, Age: {item.Age}, Cruelty: {item.CrueltyCoefficient}");
            }
        }