示例#1
0
        public void Print(string clinicName, int room)
        {
            IClinic clinic = this.clinics.FirstOrDefault(n => n.Name == clinicName);

            if (clinic == null)
            {
                // Clinic not found
                throw new InvalidOperationException("Invalid Operation!");
            }

            if (room < 1 || room > clinic.RoomsCount)
            {
                // Invalid room index
                throw new InvalidOperationException("Invalid Operation!");
            }

            Output.AddReportLine(clinic.Rooms[room - 1].IsBusy ? clinic.Rooms[room - 1].Pet.ToString() : "Room empty");
        }
示例#2
0
        public void Print(string clinicName)
        {
            try
            {
                IClinic clinic = this.clinics.FirstOrDefault(n => n.Name == clinicName);

                if (clinic == null)
                {
                    // Clinic not found
                    throw new InvalidOperationException("Invalid Operation!");
                }

                foreach (var room in clinic.Rooms)
                {
                    Output.AddReportLine(room.IsBusy ? room.Pet.ToString() : "Room empty");
                }
            }
            catch (InvalidOperationException e)
            {
                Utilities.Output.AddReportLine(e.Message);
            }
        }