-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha02.py
71 lines (50 loc) · 1.93 KB
/
a02.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class Address:
def __init__(self, house_no=0, street=0, city= " ", country = " "):
self.house_no = house_no
self.street = street
self.city = city
self.country = country
def get_full_address(self):
return "H. No. " + str(self.house_no) + ", Street " + str(self.street) + ", " + self.city + " " + self.country
def __str__(self):
return self.get_full_address()
class Employee:
def __init__(self, id=1, name=None):
self.id = id
self.name = name
self.current_address = None
self.permanent_address = None
def set_current_address(self, house_no, street, city, country):
self.current_address = Address(house_no, street, city, country)
def set_permanent_address(self, house_no, street, city, country):
self.permanent_address = Address(house_no, street, city, country)
def get_current_address(self):
return str(self.current_address)
def get_permanent_address(self):
return str(self.permanent_address)
def __str__(self):
return str(self.id) + " " + str(self.name) + " " + str(self.permanent_address)
class Lecturer(Employee):
def __init__(self):
super().__init__(1, "Mr. Bigshot")
def __str__(self):
return "Lecturer: " + super().__str__()
if __name__ == "__main__":
# Uncomment these to test out your code before run.py local
a = Address()
a.house_no = 2
a.street = 3
a.city = "Peshawar"
a.country = "Pakistan"
print(a.get_full_address())
print(a)
e = Employee()
e.set_current_address(1, 2, "Cape Town", "South Africa")
print(e.get_current_address())
e.set_permanent_address(4, 19, "Cape Town", "South Africa")
print(e.get_permanent_address())
print(e)
l = Lecturer()
l.set_permanent_address(44, 24, "KL", "Malaysia")
print(l.get_permanent_address())
print(l)