-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaseorsuperclass.py
More file actions
61 lines (37 loc) · 874 Bytes
/
baseorsuperclass.py
File metadata and controls
61 lines (37 loc) · 874 Bytes
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
#class X(object):
# def __init__(self, a):
# self.num = a
# def doubleup(self):
# self.num *= 2
#class Y(X):
# def __init__(self, a):
# X. __init__(self, a)
# def tripleup(self):
# self.num *= 3
#obj = Y(10)
#print(obj.num)
#obj.doubleup()
#print(obj.num)
#obj.tripleup()
#print(obj.num)
class Person(object):
def __init__(self, name):
self.name = name
def getName(self):
return self.name
def isEmployee(self):
return False
#Inherited or Subclass
class Employee(Person):
def __init__(self, name, eid):
# In Python 3.0+, super().__init__(name) also works
super(Employee, self).__init__(name)
self.empID = eid
def isEmployee(self):
return True
def getID(self):
return self.empID
per = Person("Faizan")
print(per.getName(), per.isEmployee())
emp = Employee("Muneer", "E1322")
print(emp.getName(), emp.isEmployee(), emp.getID())