Starting from:

$39.99

CS 115 Lab 8- Inheritance Solution



a) Create a class, Patient, with the following data members and methods. Note all data members and class variables should be private.

Data Members:
• pName: stores the string name of the patient
• isInsured: boolean field that indicates if patient has private insurance.
• coveragePercent: stores the percent (as decimal value) of the patient’s insurance coverage. Zero if not insured.

Class Variable:
• hospitalFee: stores the fee for the hospital visit, 500TL.

Methods:
• __init()__: initializes the pName, isInsured, coveragePercent (default parameter set to zero if not passed) to values passed as parameters. Should initialize coveragePercent using the set method.
• Get and set methods for all data members. The set method for coveragePercent should only set the variable if the value passed as a parameter is a positive value.
• Get method to return the value of the __hospitalFee.
• __repr()__: returns a string representation of a Patient object formatted as shown in the sample run (includes patient name and insurance information only).
• calculateFee (): calculates and returns the amount of the hospital fee the patient must pay. If the patient is insured, deduct the insurance portion.

b) Create a class, Outpatient, with the following data members and methods. Note all data members should be private.

Data Members:
• polyClinic: stores the string name of the poly clinic for the patient’s appointment.
• doctorName: stores the string name of the doctor the patient will visit.
• appointmentTime: stores the time of the appointment.

Methods:
• __init()__:
o Initialize the Patient data using the super class __init__ method. If the polyclinic is Dentistry or Optometry, the coverage percent passed as a parameter should be divided by 2.


• Get and set methods for Outpatient attributes:
o Example:

today


• __repr()__: returns a string representation of an Outpatient object. The method should call the Patient __repr__ to get the Patient data, and append the Outpatient data, formatted as shown in the sample run.

c) Write a script PatientApp with the following functions:
• schedulePatients(): takes a string filename and list of Outpatients as parameters. Reads the patient data from the file and adds the outpatients in the file to the list passed as a parameter.
• The script should do the following:
o Create an empty list to store patients.
o Schedule the patients in the file patients.txt using the function above.
o Sort the list of patients according to their appointment times. o Display the list of patients.


Sample Run:
[
Patient Name: Syreeta Coachman Insurance: (no)
Poly Clinic: Gastroenterology (Dr. Irem Basar)
Fee: 500
,
Patient Name: Charlena Tebbs Insurance: (yes)
Poly Clinic: Dentistry (Dr. Ali Ayhan)
Fee: 325.0
,
Patient Name: Arlie Peek Insurance: (no) Poly Clinic: ENT (Dr. Jale Tunç)
Fee: 500
,
Patient Name: Elwood Depaul Insurance: (no)
Poly Clinic: Optometry (Dr. Mehmet Keskin)
Fee: 500
,
Patient Name: Janell Huey Insurance: (yes) Poly Clinic: ENT (Dr. Melis Koç)
Fee: 100.0
,
Patient Name: Lenore Bechard Insurance: (yes)
Poly Clinic: Cardiology (Dr. Ayla Güner)
Fee: 325.0
,
Patient Name: Lolita Shore Insurance: (yes)
Poly Clinic: Cardiology (Dr. Veysel KarakuÅŸ)
Fee: 150.0
,
Patient Name: Maudie Plummer Insurance: (yes)
Poly Clinic: Optometry (Dr. Elif Som)
Fee: 275.0
]

More products