ex42 unfinished
This commit is contained in:
parent
fe9ebf8d8b
commit
b34580783d
1 changed files with 51 additions and 0 deletions
51
balazs/python-the-hard-way/ex42/ex42.py
Normal file
51
balazs/python-the-hard-way/ex42/ex42.py
Normal 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()
|
Loading…
Reference in a new issue