Question

The current version of the HospitalSystem Class has a method to handle each of the tasks. In general, eachmethod does the following things: Obtains user input for the data needed

for the task Checks the data for validity • Invokes the methods from other classes to do the task • Handles the result of the task Handles the result of the task For this question, your job is to refactor the tasks in the HospitalSystem class. This question will go throughthe steps in detail for one of the tasks, and when you have done the steps once, you will repeat the exercisefor the others.Study the given Java file Command.java, It defines in interface the requires a single method. public interface Command {public abstract voidexecute ((); In this question, we will move the logic of the method addDoctor() out of HospitalSystem to a new classcalled AddDoctor, with requirements to be as follows: • AddDoctor implements Command. Uses the default constructor AddDoctor () provided by Java. You don't need to write a constructor. • Has a single method public void execute() whose body is basically copy/paste from addDoctor ().If you have done everything well so far, then this is really just copy/paste from HospitalSystem to anew class AddDoctor. If you haven't quite refactored properly, you might have more trouble. Because you are using DoctorMapAccess, you have direct access to the doctors in the system. Because you are using I0Access, you can communicate to the user. When you are done, you should be able to use the following to demonstrate that the method works: public static void main(String [] args) {Command cmd =new AddDoctor ();cmd.execute();} public void addDoctor() {Command cmdnew AddDoctor ();cmd.execute ();}

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 17