-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncapsulation.py
More file actions
33 lines (24 loc) · 952 Bytes
/
Copy pathEncapsulation.py
File metadata and controls
33 lines (24 loc) · 952 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
class Person:
def __init__(self, firstname,lastname):
self.firstname = firstname
self.lastname = lastname
def show(self):
print("Person: ",self.firstname, self.lastname)
class Student(Person):
def __init__(self, firstname,lastname,indexnumber):
self.indexnumber = indexnumber
super().__init__(firstname,lastname)
def show(self):
print("Student: ",self.firstname, self.lastname,self.indexnumber)
class Professor(Person):
def __init__(self, firstname,lastname,subject):
self.subject = subject
super().__init__(firstname,lastname)
def show(self):
print("Professor: ",self.firstname, self.lastname,self.subject)
person = Person("John","Davidson")
student = Student("Will", "Smith", "10/02/009")
professor = Professor("Edward", "Owen", "Pyton programming")
person.show()
student.show()
professor.show()