Question

PatientMapAccess. This class creates a single TreeMap instance. It starts out empty. Singleton Attribute: dictionary: TreeMap Static method: getInstance (): TreeMap returns the dictionary containing allpatients known to

the system. DoctorMapAccess. This class creates a single TreeMap instance. It starts out empty. Singleton Attribute: dictionary: TreeMap Static method: getInstance(): TreeMap returns the dictionary containing alldoctors known to the system.- WardAccess. This one is a bit trickier. The problem is that the Ward constructor needs to know some initial values for the attributes (the Wardname, the first and last bed numbers). Since the HospitalSystem will interact with the Ward class onlythrough the WardAccess class, we need another static method to get the initial values to the ward. Singleton Attribute: ward Ward Static method: void initialize(String name, int first, int last) This function should cre-ate the ward, but only if it has not been created already. This static method should throw anexception if the Ward object has already been created and initialized. This exception is not onethat you should catch; it's the sign that the program has a bug, so fix the bug! Static method: getInstance(): Ward returns the ward known to the hospital system. This methodshould throw an exception if the ward has not already been created and initialized. This exceptionis not one that you should catch; it's the sign that the program has a bug, so fix the bug! • IDAccess. This class creates a single InputOutputInterface object.We want a single InputOutputInterface object that the whole HospitalSystem will use to commu-nicate with the user. It will either be a single ConsoleI0 object, or a single DialogIO object. To getthis to work, you have to ask the user. Depending on the user's answer, the 10Access class will cre-ate a ConsoleI0 object as the singleton, or a DialogIO object as the singleton. Of course, you haveto use one of these two objects to communicate with the user about the choice. For example, youcould create a ConsoleI0 object, and use it to ask which style of IO they want, and then if they chooseDialogI0, create the DialogI0 object, and use it as the singleton.- Singleton Attribute: io: InputOutputInterface- Static method: getInstance (): InputOutputInterface returns an object that implements theInputOutputInterface. Remember that the constructors for Singleton classes should be private.Once you have created these classes, revise your HospitalSystem, so that each method that needs accessto the Patients, Doctors, Ward, or InputOutputInterface uses the classes above. For example, we mightuse the following code in addDoctor(): DoctorMapAccess.getInstance ().put (name, doctor0bject); This singleton object, stored in DoctorMapAccess Ward, replaces the TreeMap attribute currently used inthe HospitalSystem. In other words, HospitalSystem will not store a reference to the TreeMap for doctors;instead it will use the dictionary provided by DoctorMapAccess. Likewise, replace the TreeMap attribute forthe the Patients with direct access to PatientMapAccess, and the Ward attribute with direct access to theWardAccess object. Finally, you should change the code in HospitalSystem to use the IOAccess object, asfollows: IOAccess.getInstance ().outputString("Invalid option:"+ task +"try again.") Once everything is working, rename the class HospitalSystemA5Q4 before handing it in to Moodle. Thisrenaming is strictly to help with marking.

Question image 1Question image 2Question image 3Question image 4Question image 5Question image 6Question image 7Question image 8Question image 9Question image 10Question image 11Question image 12Question image 13Question image 14Question image 15Question image 16Question image 17Question image 18