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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started