Time To Code: Task I to Task V

📌 Note: Before starting a task, copy the code of the previous tasks.

Task I: Design the basic structure

As previously discussed, a person in a hospital can be a doctor or a patient.

Our task is to create the classes and add the instance variables to represent these two types of people. Read the following specifications carefully.

  • Every patient and doctor has a name.

  • The age of every patient and doctor is recorded.

  • A patient is given an int type code every time he/she schedules an appointment.

  • A doctor can be a cardiologist, neurosurgeon, or dietitian.

    💡 Hint: Think of a doctor as an interface and all the types of doctors as classes.

  • The status of a doctor’s availability is also recorded. A doctor may or may not be available.

  • The hospital has a name.

  • The hospital holds the information about all cardiologists, neurosurgeons, and dietitians working.

Look at the code widget below. There are six files: Hospital.java, Patient.java, Doctor.java, Cardiologist.java, Neurosurgeon.java, and Dietitian.java.

Code the specifications above.

✏️ Note: The main is to be written in a separate Driver.java file.

Get hands-on with 1200+ tech skills courses.