Project 4: Interactive Fiction
Due Date: Nov 1st
Once upon a time, before the dawn of the Internet as we know it, there lived a forgotten type of
computer game called interactive fiction.
First written in the late '70s, these games were sort of a
choose-your-own adventure book, but for geeks.
These games contain no graphics, just a 2
(everybody remembers English class right?) description of your character, and a box for entering
With the birth of the kindle and other Internet enabled e-readers, these games are
experiencing something of a rebirth, as their screens are a perfect match for these games.
To play one for yourself, go to
Your project is to create an interactive fiction.
To help you along, a couple of classes have been written
for you, you only need to make the guts of the game, called the engine.
You should have received
Map.java, Room.java, Lamp.java, and Chest.java along with this pdf.
Begin by taking a quick a look at the Map class.
This class is completely implemented, you don't need
to do any work on it, but you do need to know how to use it.
In this game, a map is a square of size
You call the getRoom(X,Y) to retrieve the Room object for a given square.
The first number (X)
gives the row and the second (Y) gives the column.
The starting room is at (0, 0).
The description of
the interface for this class is given at the end of this pdf.
Now take a look at the Room class.
This class is implemented for you as well.
It contains a large
number of methods for you to use during the game.
As you can see, there are no setters, only getters.
This means that for the most part you cannot modify any Room objects you receive.
are the clearKey() and clearLamp() methods that modify two of the room's sub-objects.
down below when you need to call these methods.
If a room does not have a specific sub-object, its
variable will be set to null.
You will need to test for this condition to see if a room has a sub-object or
The description of the interface for this class is given at the end of this pdf.
You should NOT modify Room or Map to get your game working, your project will be tested with our
own versions of these two files, so any modifications you make could result in your project not
compiling or not working correctly.
You should start your work by implementing the Chest class (a skeleton is provided for you).
needs to store whether it is locked or not, a String describing the contents, and which key it was
The method stubs for this class are provided with comments, be sure to implement
them the way they are described.
You should not add any more methods to this class.