From b34580783d5be1e0d6345fac65bed0b884f3d1c8 Mon Sep 17 00:00:00 2001 From: llnu Date: Fri, 12 Jun 2020 17:00:35 +0200 Subject: [PATCH] ex42 unfinished --- balazs/python-the-hard-way/ex42/ex42.py | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 balazs/python-the-hard-way/ex42/ex42.py 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()