-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoop_concept.py
51 lines (36 loc) · 1.16 KB
/
oop_concept.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -------------- Single Inheritance -------------------
# create class user
class User:
def __init__(self, name, address):
self.name = name
self.address = address
def login(self):
print(F'Hi {self.name}')
user = User('Jon', 'USA')
print(user.name, user.address)
# Inherit from User
class Doctor(User):
def __init__(self,
name,
address,
specialities,
schedule,
degree):
super().__init__(name, address)
self.specialities = specialities
self.schedule = schedule
self.__degree = degree
def __diagnose_patient(self, patient):
print(F'diagnosed patient {patient.name} by doctor {self.name}')
class Patient(User):
def __init__(self, name, address, diseases):
super().__init__(name, address)
self.diseases = diseases
def get_appointment(self):
print(F'{self.name} booked appointment')
patient = Patient('Jhon', 'KTM', 'Cough')
patient.get_appointment()
doctor = Doctor('Dr. Bob', 'KTM', 'OPD', 'SUN: 7-8', 'MBBS')
# doctor.diagnose_patient(patient)
print(dir(Doctor))
doctor.login()