Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            AnimalCentre animalCentre = new AnimalCentre();
            var          type         = typeof(AnimalCentre);

            ReadCommands(animalCentre, type);

            Console.WriteLine(animalCentre.GetAdoptedAnimals());
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            var animalCentre = new AnimalCentre();

            var input = Console.ReadLine();

            while (input != "End")
            {
                var tokens = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                var command = tokens[0];
                var result  = "";
                try
                {
                    switch (command)
                    {
                    case "RegisterAnimal":
                        result = animalCentre.RegisterAnimal(tokens[1], tokens[2], int.Parse(tokens[3]), int.Parse(tokens[4]), int.Parse(tokens[5]));
                        if (result != "")
                        {
                            Console.WriteLine(result);
                        }
                        break;

                    case "Chip":
                        result = animalCentre.Chip(tokens[1], int.Parse(tokens[2]));
                        if (result != "")
                        {
                            Console.WriteLine(result);
                        }
                        break;

                    case "Vaccinate":
                        result = animalCentre.Vaccinate(tokens[1], int.Parse(tokens[2]));
                        if (result != "")
                        {
                            Console.WriteLine(result);
                        }
                        break;

                    case "Fitness":
                        result = animalCentre.Fitness(tokens[1], int.Parse(tokens[2]));
                        if (result != "")
                        {
                            Console.WriteLine(result);
                        }
                        break;

                    case "Play":
                        result = animalCentre.Play(tokens[1], int.Parse(tokens[2]));
                        if (result != "")
                        {
                            Console.WriteLine(result);
                        }
                        break;

                    case "DentalCare":
                        result = animalCentre.DentalCare(tokens[1], int.Parse(tokens[2]));
                        if (result != "")
                        {
                            Console.WriteLine(result);
                        }
                        break;

                    case "NailTrim":
                        result = animalCentre.NailTrim(tokens[1], int.Parse(tokens[2]));
                        if (result != "")
                        {
                            Console.WriteLine(result);
                        }
                        break;

                    case "Adopt":
                        result = animalCentre.Adopt(tokens[1], tokens[2]);
                        if (result != "")
                        {
                            Console.WriteLine(result);
                        }
                        break;

                    case "History":
                        result = animalCentre.History(tokens[1]);
                        if (result != "")
                        {
                            Console.WriteLine(result);
                        }
                        break;
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine("ArgumentException: " + ae.Message);
                }
                catch (InvalidOperationException ioe)
                {
                    Console.WriteLine("InvalidOperationException: " + ioe.Message);
                }

                input = Console.ReadLine();
            }

            var resultString = animalCentre.GetAdoptedAnimals();

            if (resultString != "")
            {
                Console.WriteLine(resultString);
            }
        }
Exemplo n.º 3
0
        public static void Main()
        {
            AnimalCentre ac = new AnimalCentre();

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

                try
                {
                    if (command[0] == "End")
                    {
                        Console.WriteLine(ac.GetAdoptedAnimals());
                        break;
                    }
                    else if (command[0] == "RegisterAnimal")
                    {
                        Console.WriteLine(ac.RegisterAnimal(command[1], command[2],
                            int.Parse(command[3]), int.Parse(command[4]), int.Parse(command[5])));
                    }
                    else if (command[0] == "Chip")
                    {
                        Console.WriteLine(ac.Chip(command[1], int.Parse(command[2])));
                    }
                    else if (command[0] == "Vaccinate")
                    {
                        Console.WriteLine(ac.Vaccinate(command[1], int.Parse(command[2])));
                    }
                    else if (command[0] == "Fitness")
                    {
                        Console.WriteLine(ac.Fitness(command[1], int.Parse(command[2])));
                    }
                    else if (command[0] == "Play")
                    {
                        Console.WriteLine(ac.Play(command[1], int.Parse(command[2])));
                    }
                    else if (command[0] == "DentalCare")
                    {
                        Console.WriteLine(ac.DentalCare(command[1], int.Parse(command[2])));
                    }
                    else if (command[0] == "NailTrim")
                    {
                        Console.WriteLine(ac.NailTrim(command[1], int.Parse(command[2])));
                    }
                    else if (command[0] == "Adopt")
                    {
                        Console.WriteLine(ac.Adopt(command[1], command[2]));
                    }
                    else if (command[0] == "History")
                    {
                        Console.WriteLine(ac.History(command[1]));
                    }
                }
                catch (InvalidOperationException ioe)
                {
                    Console.WriteLine($"InvalidOperationException: {ioe.Message}");
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine($"ArgumentException: {ae.Message}");
                }
            }
        }