Introduction: Hunt the Wumpus! đ
As you now know, OOP consists of encapsulation, inheritance and polymorphism. Last week focused on the syntax needed to support encapsulation. This week we'll continue with encapsulation, but lift our eyes up from the syntax details, to consider design issues. Specifically Object Oriented Design principles that guide us in choosing the classes needed to support programming in a particular problem domain.
In last week's OOP example of playing cards it was pretty obvious what the objects we had to represent were, and the interactions between those objects was fairly limited. This week we'll look at a problem domain with more objects, and more communication and connections between objects. The problem is to implement the venerable text adventure game Hunt the Wumpus. Most of the development is done as an extended case study in the week's notes, and the week's assignment will be to complete that development, and then add enhancements. (While the case study is of a game, the methods are applicable to any domain.)
The code is not subtle or tricky, but there is a lot of it to wrap your head around, so if you haven't begun studying it yet now is the time!
In the past this has been many students' favourite assignment, and I hope you'll enjoy it too.
- Object-Oriented Design (OOD)
- Preamble to Hunt the Wumpus
- About Hunt the Wumpus
- OO Analysis
- Object Attributes and Methods
- The Cave System Object(s)
- Main Routine Pseudocode
class Cave_System
- Aside: Iterative Design
class Room
class Pit
class Bat
class Wumpus
class Player
- Putting the pieces together
- New code: Initializing the bats
- New code (pointing to a missing
class):Â
shoot
 andÂArrow
s - New
code:Â
show_cheats()
- New code: Display status and warnings
- Memory diagram
- Bug: Fixing (mostly) snatch
- Aside: Data structure maintenance
- Two more (small) problems
- How'd we do?