Question: QUESTION 1 Using inheritance and composition, write the following code to create the classes and the sample run and output for the main file. A

QUESTION 1

Using inheritance and composition, write the following code to create the classes and the sample run and output for the main file.

A person has name(string) and id(int). The Person class uses a parameterized constructor to initialize its members. It also has a print function (printPerson) to display the details of its members.

o An Assistant class inherits Person and have specialty(string). This also uses a parameterized constructor to initialize its members. It also has a print function (printAssistant) to display the assistants details.

o A Doctor class inherits Person and have specialty(string). This also uses a parameterized constructor to initialize its members. It also has a print function (printDoctor) to display the doctors details. The Doctor class also includes 2 assistants (lab assistant and research assistant).

o A Patient class inherits Person and have an ailment(string). This also uses a parameterized constructor to initialize its members. It also has a print function (printDoctor) to display the patients details. The Patient class also includes a doctor object.

An Appointment class will have date, time (both strings) and a Patient object as its private member. The class will use a parameterized constructor to initialize its members. The class also includes a print method (printAppointment) to display the details of the appointment. Finally, create an appointment object in the main file and display the details as shown in the sample run and output in the next page.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!