diff --git a/balazs/python-the-hard-way/ex42/ex42.py b/balazs/python-the-hard-way/ex42/ex42.py new file mode 100644 index 0000000..d95965e --- /dev/null +++ b/balazs/python-the-hard-way/ex42/ex42.py @@ -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()