Introduction: Object-oriented programming 🎁
Welcome to the home stretch of the course. You're two thirds of the way through, and the final module is a light one, so there are only three more modules of substantive content left!
These modules cover Object-Oriented Programming or OOP. Don't worry, it's not something brand new and different, just a way of packaging the algorithms and data structures you've been working with into larger chunks called objects. This makes them even easier to reuse and to connect together into larger programs.
There is some new notation and jargon, so to help you concentrate on that we'll revisit a programming domain we've already seen, playing cards, and repackage our techniques and data structures for dealing with them into classes and objects. We'll develop a set of playing card classes in this module. Be sure to follow that development carefully, since three of your four assignment problems involve it.
(Next week we'll consider a new problem domain that has been students' favourite assignment over the years, the world of the original text adventure game "Hunt the Wumpus".)
- Object-Oriented Programming
- Encapsulation
- Inheritance
- Polymorphism
- The plan for the next three modules
- A small example: A dice class
- Python OOP Syntax
- Playing Card Classes: The Specification
- Identifying the necessary classes
- Identifying the classes' methods
- Program skeleton 1
- An invisible method! (A polymorphic aside)
- Program Skeleton 2
- An invisible class too!
- Deck methods
- Hand methods
- Card Methods
- Putting all the pieces together
- Running the whole thing
- Programming Observation 1. Assignment 9