Namnändringar
This commit is contained in:
21
Pass2/4 Inheritance.py
Executable file
21
Pass2/4 Inheritance.py
Executable file
@@ -0,0 +1,21 @@
|
||||
class Person:
|
||||
def __init__(self, first, last):
|
||||
self.firstname = first
|
||||
self.lastname = last
|
||||
|
||||
def Name(self):
|
||||
return self.firstname + " " + self.lastname
|
||||
|
||||
class Employee(Person):
|
||||
def __init__(self, first, last, staffnum):
|
||||
Person.__init__(self,first, last)
|
||||
self.staffnumber = staffnum
|
||||
|
||||
def GetEmployee(self):
|
||||
return self.Name() + ", " + self.staffnumber
|
||||
|
||||
x = Person("Marge", "Simpson")
|
||||
y = Employee("Homer", "Simpson", "1337")
|
||||
|
||||
print(x.Name())
|
||||
print(y.GetEmployee())
|
||||
Reference in New Issue
Block a user