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.

  1. Object-Oriented Design (OOD)
  2. Preamble to Hunt the Wumpus
  3. About Hunt the Wumpus
  4. OO Analysis
  5. Object Attributes and Methods
  6. The Cave System Object(s)
  7. Main Routine Pseudocode
  8. class Cave_System
  9. Aside: Iterative Design
  10. class Room
  11. class Pit
  12. class Bat
  13. class Wumpus
  14. class Player
  15. Putting the pieces together
  16. New code: Initializing the bats
  17. New code (pointing to a missing class): shoot and Arrows
  18. New code: show_cheats()
  19. New code: Display status and warnings
  20. Memory diagram
  21. Bug: Fixing (mostly) snatch
  22. Aside: Data structure maintenance
  23. Two more (small) problems
  24. How'd we do?