ex42 unfinished

This commit is contained in:
llnu 2020-06-12 17:00:35 +02:00
parent fe9ebf8d8b
commit b34580783d
1 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,51 @@
## Animal is-a object (yes, sort of confusing) look at the extra credit
class Animal(object):
Pass
## is-a
class Dog(Animal):
def __init__(self, name):
## has-a
self.name = name
## is-a
class Person(object):
def __init__(self, name):
## has-a
self.name = name
## is-a
class Employee(Person):
def __init__(self, name, salary):
## ?? hmm what is this strange magic? dunno,
super(Employee, self).__init__(name)
## has-a
self.salary = salary
## rover is-a Dog
rover = Dog("Rover")
## is-a
satan = Cat("Satan")
## is-a
mary = Person("Mary")
## ??
mary.pet = satan
## is-a-n employee, has x money
frank = Employee("Frank", 120000)
## is-a
flipper = Fish()