Beispiel #1
0
        public static void Main()
        {
            Dictionary <string, Dictionary <int, int> > dogs   = new Dictionary <string, Dictionary <int, int> >();
            Dictionary <string, Dictionary <int, int> > cats   = new Dictionary <string, Dictionary <int, int> >();
            Dictionary <string, Dictionary <int, int> > snakes = new Dictionary <string, Dictionary <int, int> >();

            string input = Console.ReadLine();

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

                if (inputParts[0].Equals("talk"))
                {
                    if (dogs.ContainsKey(inputParts[1]))
                    {
                        Dog.ProduceSound();
                    }
                    else if (cats.ContainsKey(inputParts[1]))
                    {
                        Cat.ProduceSound();
                    }
                    else if (snakes.ContainsKey(inputParts[1]))
                    {
                        Snake.ProduceSound();
                    }
                }
                else
                {
                    switch (inputParts[0])
                    {
                    case "Dog":
                        Dog dog = Dog.Parse(input);
                        dogs[dog.name]          = new Dictionary <int, int>();
                        dogs[dog.name][dog.age] = dog.numberOfLegs;
                        break;

                    case "Cat":
                        Cat cat = Cat.Parse(input);
                        cats[cat.name]          = new Dictionary <int, int>();
                        cats[cat.name][cat.age] = cat.intelligenceQuotient;
                        break;

                    case "Snake":
                        Snake snake = Snake.Parse(input);
                        snakes[snake.name]            = new Dictionary <int, int>();
                        snakes[snake.name][snake.age] = snake.crueltyCoefficient;
                        break;
                    }
                }

                input = Console.ReadLine();
            }

            DogsOutput(dogs);

            CatsOutput(cats);

            SnakesOutput(snakes);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            try
            {
                Cat rijko = new Cat("rijko", 5, "male");
                Console.WriteLine(rijko.ToString());
                rijko.ProduceSound();

                Tomcat darko = new Tomcat("darko", 3);
                Console.WriteLine(darko.ToString());
                darko.ProduceSound();

                Frog kikerana = new Frog("kikerana", 1, "female");
                Console.WriteLine(kikerana.ToString());
                kikerana.ProduceSound();

                Dog sharo = new Dog("sharo", 9);
                Console.WriteLine(sharo.ToString());
                sharo.ProduceSound();

                Animal[] animals = new Animal[] {
                    rijko,
                    darko,
                    kikerana,
                    sharo,
                    new Cat("tom", 2),
                    new Dog("zoro", 9),
                    new Cat("kotka", 4, "male")
                };

                Console.WriteLine();

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

                Console.WriteLine();


                var groupAnimals =
                    from animal in animals
                    group animal by animal.GetType().Name into typeGroup
                    select new
                {
                    typeGroup.Key,
                    AverageValue = Math.Round(typeGroup.Average(i => i.Age), 2)
                };

                foreach (var typeGroup in groupAnimals)
                {
                    Console.WriteLine("{0}s: average age is:{1}", typeGroup.Key, typeGroup.AverageValue);
                }
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            while (true)
            {
                try
                {
                    string animalType = Console.ReadLine();
                    if (animalType == "Beast!")
                    {
                        break;
                    }
                    string[] animalArgs = Console.ReadLine().Split();
                    switch (animalType)
                    {
                    case "Dog":
                        Dog dog = new Dog(animalArgs);
                        dog.GetTypeOfAnimal();
                        Console.WriteLine(dog.ToString());
                        dog.ProduceSound();
                        break;

                    case "Cat":
                        Cat cat = new Cat(animalArgs);
                        cat.GetTypeOfAnimal();
                        Console.WriteLine(cat.ToString());
                        cat.ProduceSound();
                        break;

                    case "Frog":
                        Frog frog = new Frog(animalArgs);
                        frog.GetTypeOfAnimal();
                        Console.WriteLine(frog.ToString());
                        frog.ProduceSound();
                        break;

                    case "Kitten":
                        Kitten kitten = new Kitten(animalArgs);
                        kitten.GetTypeOfAnimal();
                        Console.WriteLine(kitten.ToString());
                        kitten.ProduceSound();
                        break;

                    case "Tomcat":
                        Tomcat tomcat = new Tomcat(animalArgs);
                        tomcat.GetTypeOfAnimal();
                        Console.WriteLine(tomcat.ToString());
                        tomcat.ProduceSound();
                        break;

                    default:
                        throw new ArgumentException("Invalid input!");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
        static void Main(string[] args)
        {
            while (true)
            {
                string comand = Console.ReadLine();

                if (comand == "Beast!")
                {
                    break;
                }

                string[] input  = Console.ReadLine().Split();
                string   name   = input[0];
                int      age    = int.Parse(input[1]);
                string   gender = input[2];

                if (string.IsNullOrEmpty(name) || age < 0 || string.IsNullOrEmpty(gender))
                {
                    Console.WriteLine("Invalid input!");
                    continue;
                }

                if (comand == "Cat")
                {
                    Cat cat = new Cat(name, age, gender);
                    Console.WriteLine(cat);
                    Console.WriteLine(cat.ProduceSound());
                }

                if (comand == "Dog")
                {
                    Dog dog = new Dog(name, age, gender);
                    Console.WriteLine(dog);
                    Console.WriteLine(dog.ProduceSound());
                }

                if (comand == "Frog")
                {
                    Frog frog = new Frog(name, age, gender);
                    Console.WriteLine(frog);
                    Console.WriteLine(frog.ProduceSound());
                }

                if (comand == "Kitten")
                {
                    Kitten kitten = new Kitten(name, age);
                    Console.WriteLine(kitten);
                    Console.WriteLine(kitten.ProduceSound());
                }

                if (comand == "Tomcat")
                {
                    Tomcat tomcat = new Tomcat(name, age);
                    Console.WriteLine(tomcat);
                    Console.WriteLine(tomcat.ProduceSound());
                }
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            List <Animal> animals = new List <Animal>();
            string        cmd     = Console.ReadLine();

            while (cmd != "Beast!")
            {
                string[] tokens = Console.ReadLine()
                                  .Split(' ', StringSplitOptions.RemoveEmptyEntries);

                string name   = tokens[0];
                int    age    = int.Parse(tokens[1]);
                string gender = tokens[2];


                if (string.IsNullOrEmpty(name) ||
                    int.Parse(tokens[1]) < 0 ||
                    string.IsNullOrEmpty(gender))

                {
                    Console.WriteLine("Invalid input!");
                }
                else
                {
                    if (cmd == "Dog")
                    {
                        Dog current = new Dog(name, age, gender);
                        Console.WriteLine(current);
                        Console.WriteLine(current.ProduceSound());
                    }
                    else if (cmd == "Cat")
                    {
                        Cat currentCat = new Cat(name, age, gender);
                        Console.WriteLine(currentCat);
                        Console.WriteLine(currentCat.ProduceSound());
                    }
                    else if (cmd == "Frog")
                    {
                        Frog currentFrog = new Frog(name, age, gender);
                        Console.WriteLine(currentFrog);
                        Console.WriteLine(currentFrog.ProduceSound());
                    }
                    else if (cmd == "Tomcat")
                    {
                        Tomcat currentTom = new Tomcat(name, age);
                        Console.WriteLine(currentTom);
                        Console.WriteLine(currentTom.ProduceSound());
                    }
                    else if (cmd == "Kitten")
                    {
                        Kitten currentKitty = new Kitten(name, age);
                        Console.WriteLine(currentKitty);
                        Console.WriteLine(currentKitty.ProduceSound());
                    }
                }
                cmd = Console.ReadLine();
            }
        }
Beispiel #6
0
        public static void Main(string[] args)
        {
            while (true)
            {
                var line = System.Console.ReadLine();
                if (line == "Beast!")
                {
                    break;
                }
                var data   = System.Console.ReadLine().Split();
                var name   = data[0];
                var age    = int.Parse(data[1]);
                var gender = data[2];

                if (string.IsNullOrEmpty(name) || age < 0 || string.IsNullOrEmpty(gender))
                {
                    Console.WriteLine("Invalid input!");
                    continue;
                }

                if (line == "Cat")
                {
                    var cat = new Cat(name, age, gender);

                    Console.WriteLine(cat);
                    cat.ProduceSound();
                }
                else if (line == "Dog")
                {
                    var dog = new Dog(name, age, gender);

                    Console.WriteLine(dog);
                    dog.ProduceSound();
                }
                else if (line == "Frog")
                {
                    var frog = new Frog(name, age, gender);

                    Console.WriteLine(frog);
                    frog.ProduceSound();
                }
                else if (line == "Tomcat")
                {
                    var tomcat = new Tomcat(name, age);

                    Console.WriteLine(tomcat);
                    tomcat.ProduceSound();
                }
                else if (line == "Kitten")
                {
                    var kitten = new Kitten(name, age);

                    Console.WriteLine(kitten);
                    kitten.ProduceSound();
                }
            }
        }
Beispiel #7
0
        public static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (input == "Beast!")
                {
                    break;
                }


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

                string name   = tokens[0];
                int    age    = int.Parse(tokens[1]);
                string gender = tokens[2];

                if (age < 0)
                {
                    Console.WriteLine("Invalid input!");
                    continue;
                }

                if (input == "Frog")
                {
                    Frog frog = new Frog(name, age, gender);
                    Console.WriteLine(frog);
                    frog.ProduceSound();
                }
                else if (input == "Dog")
                {
                    Dog dog = new Dog(name, age, gender);
                    Console.WriteLine(dog);
                    dog.ProduceSound();
                }
                else if (input == "Cat")
                {
                    Cat cat = new Cat(name, age, gender);
                    Console.WriteLine(cat);
                    cat.ProduceSound();
                }
                else if (input == "Tomcat")
                {
                    Tomcat tomcat = new Tomcat(name, age);
                    Console.WriteLine(tomcat);
                    tomcat.ProduceSound();
                }
                else if (input == "Kitten")
                {
                    Kitten kitten = new Kitten(name, age);
                    Console.WriteLine(kitten);
                    kitten.ProduceSound();
                }
            }
        }
Beispiel #8
0
        public static void Main(string[] args)
        {
            string input = string.Empty;

            while ((input = Console.ReadLine()) != "Beast!")
            {
                string[] tokens = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);

                string name   = tokens[0];
                int    age    = int.Parse(tokens[1]);
                string gender = tokens[2];
                try
                {
                    switch (input)
                    {
                    case "Dog":
                        Dog dog = new Dog(name, age, gender);
                        Console.WriteLine(dog);
                        dog.ProduceSound();
                        break;

                    case "Frog":
                        Frog frog = new Frog(name, age, gender);
                        Console.WriteLine(frog);
                        frog.ProduceSound();
                        break;

                    case "Cat":
                        Cat cat = new Cat(name, age, gender);
                        Console.WriteLine(cat);
                        cat.ProduceSound();
                        break;

                    case "Kitten":
                        Kitten kitten = new Kitten(name, age);
                        Console.WriteLine(kitten);
                        kitten.ProduceSound();
                        break;

                    case "Tomcat":
                        Tomcat tomcat = new Tomcat(name, age);
                        Console.WriteLine(tomcat);
                        tomcat.ProduceSound();
                        break;

                    default:
                        throw new Exception("Invalid input!");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
        static void Main(string[] args)
        {
            while (true)
            {
                string   command = Console.ReadLine();
                string[] animals = Console.ReadLine().Split(" ").ToArray();
                string   name    = animals[0];
                int      age     = int.Parse(animals[1]);
                string   gender  = animals[2];

                if (command == "Beast!")
                {
                    break;
                }

                if (string.IsNullOrEmpty(name) || age < 0 || string.IsNullOrEmpty(gender))
                {
                    Console.WriteLine("Invalid input!");
                    continue;
                }


                if (command == "Cat")
                {
                    var cat = new Cat(name, age, gender);
                    Console.WriteLine(cat);
                    Console.WriteLine(cat.ProduceSound());
                }

                else if (command == "Dog")
                {
                    var dog = new Dog(name, age, gender);
                    Console.WriteLine(dog);
                    Console.WriteLine(dog.ProduceSound());
                }
                else if (command == "Frog")
                {
                    var frog = new Frog(name, age, gender);
                    Console.WriteLine(frog);
                    Console.WriteLine(frog.ProduceSound());
                }
                else if (command == "Kittens")
                {
                    var kittens = new Kittens(name, age, gender);
                    Console.WriteLine(kittens);
                    Console.WriteLine(kittens.ProduceSound());
                }
                else if (command == "TomCat")
                {
                    var tomCat = new TomCat(name, age, gender);
                    Console.WriteLine(tomCat);
                    Console.WriteLine(tomCat.ProduceSound());
                }
            }
        }
Beispiel #10
0
        public static void Main(string[] args)
        {
            while (true)
            {
                string line1 = Console.ReadLine();

                if (line1 == "Beast!")
                {
                    break;
                }

                string[] data   = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
                string   name   = data[0];
                int      age    = int.Parse(data[1]);
                string   gender = data[2];

                if (string.IsNullOrEmpty(name) || age < 0 || string.IsNullOrEmpty(gender))
                {
                    Console.WriteLine("Invalid input!");
                    continue;
                }

                if (line1 == "Cat")
                {
                    Cat cat = new Cat(name, age, gender);
                    Console.WriteLine(cat);
                    Console.WriteLine(cat.ProduceSound());
                }
                else if (line1 == "Dog")
                {
                    Dog dog = new Dog(name, age, gender);
                    Console.WriteLine(dog);
                    Console.WriteLine(dog.ProduceSound());
                }
                else if (line1 == "Frog")
                {
                    Frog frog = new Frog(name, age, gender);
                    Console.WriteLine(frog);
                    Console.WriteLine(frog.ProduceSound());
                }
                else if (line1 == "Tomcat")
                {
                    Tomcat tomcat = new Tomcat(name, age);
                    Console.WriteLine(tomcat);
                    Console.WriteLine(tomcat.ProduceSound());
                }
                else if (line1 == "Kitten")
                {
                    Kitten kitten = new Kitten(name, age);
                    Console.WriteLine(kitten);
                    Console.WriteLine(kitten.ProduceSound());
                }
            }
        }
Beispiel #11
0
        public static void Main(string[] args)
        {
            string type = Console.ReadLine();

            while (type != "Beast!")
            {
                string[] animalInfo = Console.ReadLine().Split();

                if (int.Parse(animalInfo[1]) < 0 || string.IsNullOrEmpty(animalInfo[2]) || string.IsNullOrEmpty(animalInfo[0]))
                {
                    Console.WriteLine("Invalid input!");
                    continue;
                }

                if (type == "Cat")
                {
                    Cat cat = new Cat(animalInfo[0], int.Parse(animalInfo[1]), animalInfo[2]);

                    Console.WriteLine(cat);
                    Console.WriteLine(cat.ProduceSound());
                }
                else if (type == "Dog")
                {
                    Dog dog = new Dog(animalInfo[0], int.Parse(animalInfo[1]), animalInfo[2]);

                    Console.WriteLine(dog);
                    Console.WriteLine(dog.ProduceSound());
                }
                else if (type == "Frog")
                {
                    Frog frog = new Frog(animalInfo[0], int.Parse(animalInfo[1]), animalInfo[2]);

                    Console.WriteLine(frog);
                    Console.WriteLine(frog.ProduceSound());
                }
                else if (type == "Kitten")
                {
                    Kitten kitten = new Kitten(animalInfo[0], int.Parse(animalInfo[1]));

                    Console.WriteLine(kitten);
                    Console.WriteLine(kitten.ProduceSound());
                }
                else if (type == "Tomcat")
                {
                    Tomcat tomcat = new Tomcat(animalInfo[0], int.Parse(animalInfo[1]));

                    Console.WriteLine(tomcat);
                    Console.WriteLine(tomcat.ProduceSound());
                }

                type = Console.ReadLine();
            }
        }
        public static void Main(string[] args)
        {
            string animalType = Console.ReadLine();

            while (animalType != "Beast!")
            {
                try
                {
                    var animalInfo = Console.ReadLine()
                                     .Split(" ")
                                     .ToArray();


                    if (animalType == "Cat")
                    {
                        Cat cat = new Cat(animalInfo[0], int.Parse(animalInfo[1]), animalInfo[2]);
                        Console.WriteLine(cat);
                        Console.WriteLine(cat.ProduceSound());
                    }
                    else if (animalType == "Tomcat")
                    {
                        Tomcat tomcat = new Tomcat(animalInfo[0], int.Parse(animalInfo[1]));
                        Console.WriteLine(tomcat);
                        Console.WriteLine(tomcat.ProduceSound());
                    }
                    else if (animalType == "Kitten")
                    {
                        Kitten kitten = new Kitten(animalInfo[0], int.Parse(animalInfo[1]));
                        Console.WriteLine(kitten);
                        Console.WriteLine(kitten.ProduceSound());
                    }
                    else if (animalType == "Dog")
                    {
                        Dog dog = new Dog(animalInfo[0], int.Parse(animalInfo[1]), animalInfo[2]);
                        Console.WriteLine(dog);
                        Console.WriteLine(dog.ProduceSound());
                    }
                    else if (animalType == "Frog")
                    {
                        Frog frog = new Frog(animalInfo[0], int.Parse(animalInfo[1]), animalInfo[2]);
                        Console.WriteLine(frog);
                        Console.WriteLine(frog.ProduceSound());
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }

                animalType = Console.ReadLine();
            }
        }
Beispiel #13
0
        public static void Main(string[] args)
        {
            string type;

            while ((type = Console.ReadLine()) != "Beast!")
            {
                string comand = Console.ReadLine();

                var comandArgs = comand.Split();
                var name       = comandArgs[0];
                var age        = int.Parse(comandArgs[1]);
                var gender     = comandArgs[2];

                if (name == "" || age < 0 || gender == "")
                {
                    Console.WriteLine("Invalid input!");
                }

                if (type == "Dog")
                {
                    Dog dog = new Dog(name, age, gender);
                    Console.WriteLine(dog.ToString());
                    dog.ProduceSound();
                }
                else if (type == "Cat")
                {
                    Cat cat = new Cat(name, age, gender);
                    Console.WriteLine(cat.ToString());
                    cat.ProduceSound();
                }
                else if (type == "Frog")
                {
                    Frog frog = new Frog(name, age, gender);
                    Console.WriteLine(frog.ToString());
                    frog.ProduceSound();
                }
                else if (type == "Kittens")
                {
                    Kitten kit = new Kitten(name, age);
                    Console.WriteLine(kit.ToString());
                    kit.ProduceSound();
                }
                else if (type == "Tomcat")
                {
                    Tomcat tom = new Tomcat(name, age);
                    Console.WriteLine(tom.ToString());
                    tom.ProduceSound();
                }
            }
        }
Beispiel #14
0
        public static void Main(string[] args)
        {
            string input = Console.ReadLine();

            while (input != "Beast!")
            {
                if (input == "Cat")
                {
                    string[] tokens = Console.ReadLine().Split();
                    Cat      cat    = new Cat(tokens[0], int.Parse(tokens[1]), tokens[2]);
                    Console.WriteLine(cat);
                    Console.WriteLine(cat.ProduceSound());
                }
                else if (input == "Frog")
                {
                    string[] tokens = Console.ReadLine().Split();
                    Frog     frog   = new Frog(tokens[0], int.Parse(tokens[1]), tokens[2]);
                    Console.WriteLine(frog);
                    Console.WriteLine(frog.ProduceSound());
                }
                else if (input == "Dog")
                {
                    string[] tokens = Console.ReadLine().Split();
                    Dog      dog    = new Dog(tokens[0], int.Parse(tokens[1]), tokens[2]);
                    Console.WriteLine(dog);
                    Console.WriteLine(dog.ProduceSound());
                }
                else if (input == "Tomcat")
                {
                    string[] tokens = Console.ReadLine().Split();
                    Tomcat   tomcat = new Tomcat(tokens[0], int.Parse(tokens[1]));
                    Console.WriteLine(tomcat);
                    Console.WriteLine(tomcat.ProduceSound());
                }
                else if (input == "Kitten")
                {
                    string[] tokens = Console.ReadLine().Split();
                    Kitten   kitten = new Kitten(tokens[0], int.Parse(tokens[1]));
                    Console.WriteLine(kitten);
                    Console.WriteLine(kitten.ProduceSound());
                }
                input = Console.ReadLine();
            }
        }
Beispiel #15
0
        public static void Main(string[] args)
        {
            // input
            string input = string.Empty;

            while ((input = Console.ReadLine()) != "Beast!")
            {
                string[] data = Console.ReadLine().Split();

                string name   = data[0];
                int    age    = int.Parse(data[1]);
                string gender = data[2];

                if (input == "Cat")
                {
                    var cat = new Cat(name, age, gender);
                    Console.WriteLine(cat.ProduceSound());
                }

                else if (input == "Dog")
                {
                    var dog = new Dog(name, age, gender);
                    Console.WriteLine(dog.ProduceSound());
                }

                else if (input == "Frog")
                {
                    var frog = new Frog(name, age, gender);
                    Console.WriteLine(frog.ProduceSound());
                }

                else if (input == "Kitten")
                {
                    var kitten = new Kitten(name, age);
                    Console.WriteLine(kitten.ProduceSound());
                }

                else if (input == "Tomcat")
                {
                    var tomcat = new Tomcat(name, age);
                    Console.WriteLine(tomcat.ProduceSound());
                }
            }
        }
Beispiel #16
0
        private static void CreateAnimal(string animalType)
        {
            string[] input  = Console.ReadLine().Split();
            string   name   = input[0];
            int      age    = int.Parse(input[1]);
            string   gender = input[2];

            switch (animalType)
            {
            case "Dog":
                Dog dog = new Dog(name, age, gender);
                Console.WriteLine(dog);
                dog.ProduceSound();
                break;

            case "Cat":
                Cat cat = new Cat(name, age, gender);
                Console.WriteLine(cat);
                cat.ProduceSound();
                break;

            case "Frog":
                Frog frog = new Frog(name, age, gender);
                Console.WriteLine(frog);
                frog.ProduceSound();
                break;

            case "Kitten":
                Kitten kitten = new Kitten(name, age, gender);
                Console.WriteLine(kitten);
                kitten.ProduceSound();
                break;

            case "Tomcat":
                Tomcat tomcat = new Tomcat(name, age, gender);
                Console.WriteLine(tomcat);
                tomcat.ProduceSound();
                break;

            default:
                throw new ArgumentException(Animal.ERROR_MESSAGE);
            }
        }
        public void Run()
        {
            string animal = Console.ReadLine();

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

            while (true)
            {
                string name   = properties[0];
                int    age    = int.Parse(properties[1]);
                string gender = string.Empty;

                if (age <= 0)
                {
                    Console.WriteLine("Invalid input!");


                    animal = Console.ReadLine();

                    if (animal == "Beast!")
                    {
                        break;
                    }

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

                    continue;
                }

                if (properties.Length > 2)
                {
                    gender = properties[2];
                }

                switch (animal)
                {
                case "Cat":
                {
                    Console.WriteLine(animal);
                    Cat cat = new Cat(name, age, gender);
                    Console.WriteLine(cat);
                    Console.WriteLine(cat.ProduceSound());
                }
                break;

                case "Dog":
                {
                    Dog dog = new Dog(name, age, gender);
                    Console.WriteLine(animal);
                    Console.WriteLine(dog);
                    Console.WriteLine(dog.ProduceSound());
                }
                break;

                case "Frog":
                {
                    Console.WriteLine(animal);
                    Frog frog = new Frog(name, age, gender);
                    Console.WriteLine(frog);
                    Console.WriteLine(frog.ProduceSound());
                }
                break;

                case "Tomcat":
                {
                    Console.WriteLine(animal);
                    Tomcat tomcat = new Tomcat(name, age);
                    Console.WriteLine(tomcat);
                    Console.WriteLine(tomcat.ProduceSound());
                }
                break;

                case "Kitten":
                {
                    Console.WriteLine(animal);
                    Kitten kitten = new Kitten(name, age);
                    Console.WriteLine(kitten);
                    Console.WriteLine(kitten.ProduceSound());
                }
                break;
                }
                animal = Console.ReadLine();

                if (animal == "Beast!")
                {
                    break;
                }

                properties = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            }
        }
        public static void Main(string[] args)
        {
            while (true)
            {
                try
                {
                    var animal = Console.ReadLine();

                    if (animal == "Beast!")
                    {
                        break;
                    }

                    var animaInfo = Console.ReadLine().Split(" ");

                    var name = animaInfo[0];
                    int age;
                    if (!int.TryParse(animaInfo[1], out age))
                    {
                        throw new ArgumentException("Invalid input!");
                    }
                    var gender = animaInfo[2];

                    if (animal == "Cat")
                    {
                        Console.WriteLine(animal);
                        Cat cat = new Cat(name, age, gender);
                        Console.WriteLine(cat);
                        cat.ProduceSound();
                    }
                    else if (animal == "Dog")
                    {
                        Console.WriteLine(animal);
                        Dog dog = new Dog(name, age, gender);
                        Console.WriteLine($"{dog}");
                        dog.ProduceSound();
                    }
                    else if (animal == "Frog")
                    {
                        Console.WriteLine(animal);
                        Frog frog = new Frog(name, age, gender);
                        Console.WriteLine(frog);
                        frog.ProduceSound();
                    }
                    else if (animal == "Kitten")
                    {
                        Console.WriteLine(animal);
                        Kitten kitten = new Kitten(name, age);
                        Console.WriteLine($"{kitten}");
                        kitten.ProduceSound();
                    }
                    else if (animal == "Tomcat")
                    {
                        Console.WriteLine(animal);
                        Tomcat tomcat = new Tomcat(name, age);
                        Console.WriteLine($"{tomcat}");
                        tomcat.ProduceSound();
                    }
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
        static void Main()
        {
            var animal = Console.ReadLine();

            while (!animal.Equals("Beast!"))
            {
                try
                {
                    var animalInfo = Console.ReadLine()
                                     .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    var animalName   = animalInfo[0];
                    var animalAge    = int.Parse(animalInfo[1]);
                    var animalGender = animalInfo[2];

                    switch (animal)
                    {
                    case "Dog":
                        var dog = new Dog(animalName, animalAge, animalGender);
                        Console.Write(dog);
                        dog.ProduceSound();
                        break;

                    case "Frog":
                        var frog = new Frog(animalName, animalAge, animalGender);
                        Console.Write(frog);
                        frog.ProduceSound();
                        break;

                    case "Cat":
                        var cat = new Cat(animalName, animalAge, animalGender);
                        Console.Write(cat);
                        cat.ProduceSound();
                        break;

                    case "Kitten":
                        var kitten = new Kitten(animalName, animalAge, "Female");
                        Console.Write(kitten);
                        kitten.ProduceSound();
                        break;

                    case "Tomcat":
                        var tomcat = new Tomcat(animalName, animalAge, "Male");
                        Console.Write(tomcat);
                        tomcat.ProduceSound();
                        break;

                    case "Animal":
                        Console.WriteLine("Not implemented!");
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid input!");
                }

                animal = Console.ReadLine();
            }
        }