python-CSD-kursu/python-temel/aggregation.2.py
2023-06-27 18:18:26 +03:00

29 lines
606 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class Doctor:
def __init__(self, name, specialty):
self.name = name
self.specialty = specialty
def disp(self):
print(f'{self.name}, {self.specialty}')
class Hospital:
def __init__(self):
self.doctors = []
def add_doctor(self, doctor):
self.doctors.append(doctor)
def disp(self):
for doctor in self.doctors:
doctor.disp()
hospital = Hospital()
doctor1 = Doctor('Ali Serçe', 'İç Hastalıkları')
doctor2 = Doctor('Medeni Demir', 'Psikiyatri')
hospital.add_doctor(doctor1)
hospital.add_doctor(doctor2)
hospital.disp()