Beispiel #1
0
        private void Print(string clinicName)
        {
            Clinic clinic = GetClinic(clinicName);

            Console.WriteLine(clinic);
        }
Beispiel #2
0
        private void Print(string clinicName, int roomNumber)
        {
            Clinic clinic = GetClinic(clinicName);

            Console.WriteLine(clinic[roomNumber - 1]);
        }
Beispiel #3
0
 public int CompareTo(Clinic clinicName)
 {
     return(this.Name.CompareTo(clinicName.Name));
 }
Beispiel #4
0
        public static void Main()
        {
            var numberOfCommands = int.Parse(Console.ReadLine());
            var pets             = new List <Pet>();
            var clinics          = new List <Clinic>();

            var commandLine = Console.ReadLine();

            for (int i = 0; i < numberOfCommands; i++)
            {
                var tokens  = commandLine.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                var command = tokens[0];

                if (command == "Create")
                {
                    var type = tokens[1];
                    var name = tokens[2];
                    if (type == "Pet")
                    {
                        var age    = int.Parse(tokens[3]);
                        var kind   = tokens[4];
                        var newPet = new Pet(name, age, kind);
                        pets.Add(newPet);
                    }
                    else
                    {
                        var rooms     = int.Parse(tokens[3]);
                        var newClinic = new Clinic(name, rooms);
                        clinics.Add(newClinic);
                    }
                }
                else if (command == "Add")
                {
                    var petName       = tokens[1];
                    var clinicName    = tokens[2];
                    var currentClinic = clinics.FirstOrDefault(x => x.Name == clinicName);
                    var currentPet    = pets.FirstOrDefault(x => x.Name == petName);

                    if (currentClinic != null && currentPet != null)
                    {
                        Console.WriteLine(currentClinic.AddPet(currentPet));
                    }
                    else
                    {
                        throw new InvalidOperationException("Invalid Operation!");
                    }
                }
                else if (command == "Release")
                {
                    var currentClinic = ValidateClinic(tokens[1], clinics);
                    Console.WriteLine(currentClinic.Release());
                }
                else if (command == "HasEmptyRooms")
                {
                    var currentClinic = ValidateClinic(tokens[1], clinics);
                    Console.WriteLine(currentClinic.GetEmptyRoomsAvailable());
                }
                else if (command == "Print" && tokens.Length == 2)
                {
                    var currentClinic = ValidateClinic(tokens[1], clinics);
                    currentClinic.Print();
                }
                else if (command == "Print" && tokens.Length == 3)
                {
                    var currentRoom   = int.Parse(tokens[2]);
                    var currentClinic = ValidateClinic(tokens[1], clinics);
                    currentClinic.Print(currentRoom);
                }

                commandLine = Console.ReadLine();
            }
        }
Beispiel #5
0
        private static void ReleasePetFromClinic(string clinicName)
        {
            Clinic currentClinic = allClinics[clinicName];

            Console.WriteLine(currentClinic.TryReleasePet());
        }
Beispiel #6
0
        private static void CheckForEmptyRooms(string clinicName)
        {
            Clinic currentClinic = allClinics[clinicName];

            Console.WriteLine(currentClinic.HasEmptyRooms());
        }