Knowee
Questions
Features
Study Tools

Give the definition of four classes, Person, Doctor, Patient and Billing, whose objects are records for a clinic. Class Doctor will be derived from the class Person. A doctor have it’s specialty and  feesPatient will be derived from the class Person. A Patient record no_of_days_admitted and a Doctor object.A Billing object will contain a Patient object, Be sure your classes have a reasonable complement of constructors.First write a driver program to test all your member functions, and  creates at least two patients, at least two doctors, and at least two Billing recordsAt the time of Billing the Patient’s Doctor  name and Billing object’s doctor name equality should be checked.Total bill generated will be no of days the patient admitted * doctor's fees.

Question

Give the definition of four classes, Person, Doctor, Patient and Billing, whose objects are records for a clinic. Class Doctor will be derived from the class Person. A doctor have it’s specialty and  feesPatient will be derived from the class Person. A Patient record no_of_days_admitted and a Doctor object.A Billing object will contain a Patient object, Be sure your classes have a reasonable complement of constructors.First write a driver program to test all your member functions, and  creates at least two patients, at least two doctors, and at least two Billing recordsAt the time of Billing the Patient’s Doctor  name and Billing object’s doctor name equality should be checked.Total bill generated will be no of days the patient admitted * doctor's fees.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution 1

Here is a Python implementation of the classes Person, Doctor, Patient, and Billing:

class Person:
    def __init__(self, name):
        self.name = name

class Doctor(Person):
    def __init__(self, name, specialty, fees):
        super().__init__(name)
        self.specialty = specialty
        self.fees = fees

class Patient(Person):
    def __init__(self, name, no_of_days_admitted, doctor):
        super().__init__(name)
        self.no_of_days_admitted = no_of_days_admitted
        self.doctor = doctor

class Billing:
    def __init__(self, patient):
        self.patient = patient

    def generate_bill(self):
        if self.patient.doctor.name != self.patient.name:
            raise ValueError("Patient's doctor name and Billing object's doctor name do not match.")
        return self.patient.no_of_days_admitted * self.patient.doctor.fees

Here is a driver program to test all the member functions:

def main():
    # Create two doctors
    doctor1 = Doctor("Dr. Smith", "Cardiology", 500)
    doctor2 = Doctor("Dr. Johnson", "Neurology", 600)

    # Create two patients
    patient1 = Patient("John Doe", 2, doctor1)
    patient2 = Patient("Jane Doe", 3, doctor2)

    # Create two Billing records
    billing1 = Billing(patient1)
    billing2 = Billing(patient2)

    # Generate bills
    print("Bill for patient 1: ", billing1.generate_bill())
    print("Bill for patient 2: ", billing2.generate_bill())

if __name__ == "__main__":
    main()

This program first creates two doctors and two patients. Each patient is assigned a doctor. Then, two Billing records are created for each patient. Finally, the total bill for each patient is calculated and printed.

This problem has been solved

Solution 2

Here is a Python implementation of the classes you described:

class Person:
    def __init__(self, name):
        self.name = name

class Doctor(Person):
    def __init__(self, name, specialty, fees):
        super().__init__(name)
        self.specialty = specialty
        self.fees = fees

class Patient(Person):
    def __init__(self, name, no_of_days_admitted, doctor):
        super().__init__(name)
        self.no_of_days_admitted = no_of_days_admitted
        self.doctor = doctor

class Billing:
    def __init__(self, patient):
        self.patient = patient

    def generate_bill(self):
        if self.patient.doctor.name == self.patient.name:
            return self.patient.no_of_days_admitted * self.patient.doctor.fees
        else:
            return "Doctor's name and Patient's name do not match."

# Driver program
doc1 = Doctor("Dr. Smith", "Cardiology", 500)
doc2 = Doctor("Dr. Johnson", "Neurology", 600)

pat1 = Patient("John Doe", 2, doc1)
pat2 = Patient("Jane Doe", 3, doc2)

bill1 = Billing(pat1)
bill2 = Billing(pat2)

print(bill1.generate_bill())  # Output: "Doctor's name and Patient's name do not match."
print(bill2.generate_bill())  # Output: "Doctor's name and Patient's name do not match."

In this code, we first define the Person class with a name attribute. We then define the Doctor and Patient classes, which inherit from Person and add their own additional attributes. The Billing class contains a Patient object and a method to generate a bill, which checks if the doctor's name matches the patient's name and, if so, calculates the total bill based on the number of days the patient was admitted and the doctor's fees. The driver program then creates two doctors, two patients, and two billing records, and tests the generate_bill method.

This problem has been solved

Similar Questions

Write three best suitable attributes of the following classesQuestion 1Class Medicine

Suppose you are tasked with designing a program to model different types of employees in a company. Define three classes: Employee, Manager, and Developer, each with specific attributes and functionalities. 1.Employee Class: •Attributes: name (string), employeeId (integer), and salary (double). •Implement a constructor to initialize the name, employeeId, and salary attributes. •Implement a member function displayDetails() to display the name, employee ID, and salary of the employee. 2.Manager Class (Derived from Employee): •Attributes: department (string). •Implement a constructor to initialize the name, employeeId, salary, and department attributes. •Implement a member function displayDetails() to display the name, employee ID, salary, and department of the manager. 3.Developer Class (Derived from Employee): •Attributes: programmingLanguage (string). •Implement a constructor to initialize the name, employeeId, salary, and programmingLanguage attributes. •Implement a member function displayDetails() to display the name, employee ID, salary, and programming language of the developer. INPUT/OUTPUT EXAMPLE: Enter employee name: JAHANGEER Enter employee ID: 1 Enter employee salary: $5000 Enter manager name: JOHN Enter manager ID: 2 Enter manager salary: $6000 Enter manager department: RANDD Enter developer name: KEATS Enter developer ID: 3 Enter developer salary: $4000 Enter developer programming language: C Employee Details: Name: JAHANGEER Employee ID: 1 Salary: $5000 Manager Details: Name: JOHN Employee ID: 2 Salary: $6000 Department: RANDD Developer Details: Name: KEATS Employee ID: 3 Salary: $4000 Programming Language: C<iostream>

Considering the tables of the Hospital database given below, identify candidate keys, primarykeys, and foreign keys. Also, give an example of derived attributes for patient and doctor.patients (patient-id, name, Date of Birth, insurance, date-admitted, date-checked-out)doctors (doctor-id, NIC, name, date of birth, specialization)test (testid, test_name, date, time, result)doctor-patient (patient-id, doctor-id)test-log (testid, patient-id)performed-by (testid, doctor-id)

A hospital wants to create a database regarding its indoor patients. The information to store includes(a) Name of patient(b)Date of admission(c)Disease(d)Date of dischargeUse the Date class created in previous program to store the date. The patient class comprises of The memberfunctions to enter the information and display the list of all patients in database using oops in c++

Which are entities of a patient data base in a doctor's office which has one doctor?*1 pointpatient, doctorpatient, visitdoctor, sicknesspatient, office

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.