Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON please refer to the code below and Add more objects , delete one record update one of the attributes, and search --------- class Hospital:

PYTHON
please refer to the code below
and Add more objects , delete one record update one of the attributes, and search
---------
class Hospital:
def __init__(self):
self.patients = []
self.doctors = []
def add_patient(self, patient):
self.patients.append(patient)
def add_doctor(self, doctor):
self.doctors.append(doctor)
def remove_patient(self, patient):
self.patients.remove(patient)
def remove_doctor(self, doctor):
self.doctors.remove(doctor)
def update_patient(self, patient, updated_patient):
self.patients.remove(patient)
self.patients.append(updated_patient)
def update_doctor(self, doctor, updated_doctor):
self.doctors.remove(doctor)
self.doctors.append(updated_doctor)
def view_all_records(self, index):
if index == 0:
for i in range(len(ls)):
print(f'Patient Name: {ls[i].name} | Age: {ls[i].age} | Gender: {ls[i].gender} | Disease: {ls[i].disease} | Doctor Name: {ls[i].doctor_name} | Blood Type: {ls[i].blood_type}')
else:
for j in range(len(ls)):
print(f'Doctor Name: {ls[j].name} | Specialty: {ls[j].specialty} | Experience: {ls[j].experience}')
class Patient(Hospital):
def __init__(self, name, age, gender, disease, doctor_name, blood_type):
self.name = name
self.age = age
self.gender = gender
self.disease = disease
self.doctor_name = doctor_name
self.blood_type = blood_type
class Doctor(Hospital):
def __init__(self, name, specialty, experience):
self.name = name
self.specialty = specialty
self.experience = experience
ls = [] #list of patients....define another one for doctors
ls.append(Patient('andy', 23, 'M', 'COVID', 'Adams', 'C-'))
Hospital.view_all_records(ls,0)
ls=[]
ls.append(Doctor("Adams","RDS","20 Years"))
Hospital.view_all_records(ls,1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions