diff --git a/sami/learn-python-the-hard-way/ex42.py b/sami/learn-python-the-hard-way/ex42.py new file mode 100644 index 0000000..9dc58f2 --- /dev/null +++ b/sami/learn-python-the-hard-way/ex42.py @@ -0,0 +1,89 @@ + ## Animal is-a object (yes, sort of confusing) look at the extra credit + class Animal(object): + + pass + + ## dog has an attribute + class Dog(Animal): + + + def __init__(self, name): + ## ?? + + self.name + + +## +class Cat(Animal): + + + def __init__(self, name): + ## ?? + self.name = name + +## ?? +class Person(object): + + + def __init__(self, name): + ## ?? + self.name = name + + + ## Person has-a pet of some kind194 + + self.pet = None + + +## ?? +class Employee(Person): + + + def __init__(self, name, salary): + ## ?? hmm what is this strange magic? + super(Employee, self).__init__(name) + ## ?? + self.salary = salary + +## ?? +class Fish(object): + + pass + +## ?? +class Salmon(Fish): + + pass + +## ?? +class Halibut(Fish): + + pass + +## rover is-a Dog +rover = Dog("Rover") + +## ?? +satan = Cat("Satan") + +## ?? +mary = Person("Mary") + +## ?? +mary.pet = satan + +## ?? +frank = Employee("Frank", 120000) + +## ?? +frank.pet = rover + +## ?? +flipper = Fish() + +## ?? +crouse = Salmon() + + +## ?? + harry = Halibut()