class: middle # .eight[CSET 160:] ## .eight[Web Development II] --- class: middle # OOP: is-a vs has-a --- # Label [Exercise 32](https://github.com/ts-cset/cset-160/blob/master/python/ex32.py) Find all the: - classes - objects - methods - attributes --- # Zen Koan # .eight[What is the difference between a fish and a koi?] --- # Speaking Object-Oriented - **inheritance**: concept of one class getting traits from another class, like you from your parents - **composition**: concept of one class being built up from other classes as parts, like a car having wheels - **is-a**: phrase used to show inheritance, a "koi" **is-a** "fish" - **has-a**: phrase used to show composition, a "koi" **has-a** "tail" --- # [Exercise 33](https://github.com/ts-cset/cset-160/blob/master/python/ex33.py) Use the "is-a" and "has-a" phrases to replace each "??" comment in the code. --- # Exercise 33 - What is the difference between .eight[class Name(object)] and .eight[class Name()]? Which should you use? - Add some functions and variables to the classes that make them do things. How would some of these classes "inherit" these functions and variables? - What does .eight[super()] do? --- # .fourteen[Go through Chapter 43 from the book.]