private static void PrintClinicRooms(List <Clinic> clinics, List <string> commandArgs)
    {
        Clinic currentClinicPrint = clinics.FirstOrDefault(c => c.Name == commandArgs[1]);

        if (commandArgs.Count == 3)
        {
            Console.WriteLine(currentClinicPrint.PrintRoom(int.Parse(commandArgs[2])));
        }
        else
        {
            Console.WriteLine(currentClinicPrint.PrintAllRooms());
        }
    }
Example #2
0
        public void Run()
        {
            var numberOfCommands = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOfCommands; i++)
            {
                var input = Console.ReadLine().Split();

                var    command = input[0];
                var    name    = string.Empty;
                Clinic clinic  = null;
                Pet    pet     = null;


                switch (command)
                {
                case "Create":
                    if (input.Length > 4)
                    {
                        pet = CreatePet(input);
                        this.pets.Add(pet);
                    }
                    else
                    {
                        clinic = CreateClinic(input);
                        this.clinics.Add(clinic);
                    }
                    break;

                case "Add":
                    var petToAdd = this.pets.
                                   First(p => p.Name == input[1]);

                    clinic = this.clinics.
                             First(c => c.Name == input[2]);

                    Console.WriteLine(clinic.AddPet(petToAdd));
                    break;

                case "Release":
                    clinic = this.clinics.
                             First(c => c.Name == input[1]);

                    Console.WriteLine(clinic.Release());
                    break;

                case "HasEmptyRooms":
                    clinic = this.clinics.
                             First(c => c.Name == input[1]);
                    Console.WriteLine(clinic.HasEmptyRooms());
                    break;

                case "Print":
                    clinic = this.clinics.
                             First(c => c.Name == input[1]);

                    if (input.Length > 2)
                    {
                        var roomID = int.Parse(input[2]);
                        clinic.PrintRoom(roomID);
                    }
                    else
                    {
                        clinic.PrintAllRooms();
                    }
                    break;
                }
            }
        }