Exemplo n.º 1
0
        private static void Refresh(string[] tokens, Department department, Doctor doctor, Patient patient)
        {
            if (!departments.Any(d => d.Rooms.Any(r => r.Patients.Any(p => p.Name == patient.Name))))
            {
                department.SettlePatient(patient);

                if (departments.Any(d => d.Name == tokens[0]))
                {
                    departments[departments.IndexOf(departments.First(d => d.Name == tokens[0]))] = department;
                }
                else
                {
                    departments.Add(department);
                }

                if (doctors.Contains(doctor))
                {
                    doctors[doctors.IndexOf(doctor)].AddPatient(patient);
                }
                else
                {
                    doctor.AddPatient(patient);
                    doctors.Add(doctor);
                }
            }
        }
Exemplo n.º 2
0
        public static void Main()
        {
            Hospital hospital = new Hospital();

            string command = Console.ReadLine();

            while (command != "Output")
            {
                string[] parts           = command.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string   departamentName = parts[0];
                string   doctorName      = String.Join(" ", parts[1], parts[2]);
                string   patientName     = parts[3];

                Department department = hospital.GetDepartment(departamentName);

                if (department.GetCountPatients() < 60)
                {
                    Room room = department.GetRoom();

                    Patient patient = new Patient(patientName);
                    room.AddPatient(patient);
                    department.AddPatient(patient);

                    Doctor doctor = hospital.GetDoctor(doctorName);
                    doctor.AddPatient(patient);
                }

                command = Console.ReadLine();
            }

            command = Console.ReadLine();

            while (command != "End")
            {
                string[] commandParts = command.Split();

                if (commandParts.Length == 1)
                {
                    Department department = hospital.GetDepartment(commandParts[0]);
                    Console.WriteLine(department);
                }
                else if (commandParts.Length == 2 && int.TryParse(commandParts[1], out int numberOfRoom))
                {
                    string     departmentName = commandParts[0];
                    Department department     = hospital.GetDepartment(departmentName);
                    int        roomName       = int.Parse(commandParts[1]);
                    Room       room           = department.GetRoom(roomName);
                    Console.WriteLine(room);
                }
                else
                {
                    string doctorName = commandParts[0] + commandParts[1];
                    Doctor doctor     = hospital.GetDoctor(doctorName);
                    Console.WriteLine(doctor);
                }
                command = Console.ReadLine();
            }
        }