52 lines
754 B
Python
52 lines
754 B
Python
|
## 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()
|