Exemple #1
0
        static void Main(string[] args)
        {
            string        input       = Console.ReadLine();
            List <Animal> healAnimal  = new List <Animal>();
            List <Animal> rehabAnimal = new List <Animal>();

            while (input != "End")
            {
                string[] tokens = input.Split();

                string       name        = tokens[0];
                string       breed       = tokens[1];
                string       healOrRehab = tokens[2];
                AnimalClinic animals     = new AnimalClinic(new Animal(name, breed));
                switch (healOrRehab)
                {
                case "heal":
                    Console.WriteLine("Patient " + AnimalClinic.PatientCounter +
                                      $": [{name} ({breed})] has been healed!");
                    AnimalClinic.Heal();
                    healAnimal.Add(new Animal(name, breed));
                    //healAnimal.Add(new Animal(name, breed));
                    break;

                case "rehabilitate":
                    Console.WriteLine("Patient " + AnimalClinic.PatientCounter +
                                      $": [{name} ({breed})] has been rehabilitated!");
                    AnimalClinic.Rehabilite();
                    //rehabAnimal.Add(new Animal(name, breed));
                    rehabAnimal.Add(new Animal(name, breed));
                    break;
                }

                input = Console.ReadLine();
            }
            string command = Console.ReadLine();

            Console.WriteLine("Total healed animals: " + AnimalClinic.HealedAnimalsCount);
            Console.WriteLine("Total rehabilitated animals: " + AnimalClinic.RehabilitedAnimalsCount);
            switch (command)
            {
            case "heal":
                foreach (var animal in healAnimal)
                {
                    Console.WriteLine(animal);
                }
                break;

            case "rehabilitate":
                foreach (var animal in rehabAnimal)
                {
                    Console.WriteLine(animal);
                }
                break;
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            string        line         = Console.ReadLine();
            List <Animal> healted      = new List <Animal>();
            List <Animal> rehabilitate = new List <Animal>();

            while (line != "End")
            {
                string[] input        = line.Split();
                string   name         = input[0];
                string   breed        = input[1];
                string   manipulation = input[2];
                switch (manipulation)
                {
                case "heal":
                    Animal a = new Animal(name, breed);
                    Console.WriteLine($"Patient {Animal.PatientId}: [{name} ({breed})] has been healed!");
                    AnimalClinic.Heal();
                    healted.Add(a);
                    break;

                case "rehabilitate":
                    Animal animal = new Animal(name, breed);
                    Console.WriteLine($"Patient {Animal.PatientId}: [{name} ({breed})] has been rehabilitated!");
                    AnimalClinic.Rehabilite();
                    rehabilitate.Add(animal);
                    break;
                }
                line = Console.ReadLine();
            }
            Console.WriteLine($"Total healed animals: {AnimalClinic.HealedAnimalsCount}");
            Console.WriteLine($"Total rehabilitated animals: {AnimalClinic.RehabilitedAnimalsCount}");

            line = Console.ReadLine();
            if (line == "heal")
            {
                string res = string.Join("\n", healted.Select(h => h.Name + " " + h.Breed));
                Console.WriteLine(res);
            }
            else if (line == "rehabilitate")
            {
                string res = string.Join("\n", rehabilitate.Select(h => h.Name + " " + h.Breed));
                Console.WriteLine(res);
            }
        }