aggregation 2
This commit is contained in:
parent
cb5a9a43c4
commit
0bef4ab495
28
python-temel/aggregation.2.py
Normal file
28
python-temel/aggregation.2.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
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()
|
4
python-temel/aggregation.2.py~
Normal file
4
python-temel/aggregation.2.py~
Normal file
|
@ -0,0 +1,4 @@
|
|||
class Doctor:
|
||||
def __init__(self, name, specialty):
|
||||
self.name = name
|
||||
self.specialty = specialty
|
Loading…
Reference in New Issue
Block a user