Python Reading
- Read the chapter entitled Inheritance:
from section "Pillars of Inheritance" to section "Extending".
Key Ideas
- Terminology: OOP supports encapsulation by packing data
and the methods that manipulate that data together.
- Terminology: OOP supports information hiding by allowing
objects to protect their data from being directly manipulated.
Instead, users of that object must use publicly available methods.
Python supports information hiding but we will not cover
this topic in CSCI 127.
- Terminology: One class can inherit the state variables and methods
from another class. This is known as inheritance.
- For example, the class student is a subclass of person.
For example, the class teacher is a subclass of person.
In-Class Activity
- The program dungeons.py illustrates
the concept of inheritance in the context of Dungeons and Dragons.
Make sure you fully understand this example.
- Draw a picture of the inheritance hierarchy.
Active Learning
- Modify the Dungeons and Dragons program to enable another
character type (such as an elf or a dwarf) to be created.
Test your program to make sure that it works properly.
- Add appropriate comments to the program. Ask someone
to check that you have done so in an appropriate manner.
- Make an additional interesting enhancement to the program.