Comp 101 Lab4: A basic text "game"
Due at 11:59pm On Mon Nov 12 (note that this is a holiday weekend)
In this lab you will begin to create a very very simple "text adventure
game". These types of programs are also being called "Interactive
Fiction" these days. You will discribe a situation to the users and
then present the user with a small series of choices. The user will
choose one, which will then move the game/story along. You have free
reign to design any G-PG rated theme you want for your story/game.
- work with multiple Java classes and files
- use selection through if /else
- work with command line text I/O
First copy the file Lab4Start.zip from my home directory as you have done in the past with other starter files.
cp /home/bscstaff/jsantore/Lab4Start.zip .
then unzip the file. You'll see that you have a folder called lab4 with three java files and a UML diagram in the folder.
You will work with 3 classes that I've generated using the umbrello UML
tool. The UML class diagram is available in case you want to work with
it, but I've already used it to generate some starter code for you all
to work with. This is the UML diagram for the project you will work on.
You will fill out several of the methods in this diagram and add a
couple of your own methods.
Many of the methods listed here have extensive comments in the code itself, however I'll briefly summarize the classes here
- The Player class: handles interaction with the player/user of the program.
- There is a _name instance variable which holds the player/character's name.
- setName allow another object to change the name if needed
- getMove should query the user for the move he/she wants to make and return that move as a string
- The Story class represents the actual game/strory.
- The _whichRoom instance variable represents what room the player is in. (which is largely for an expansion lab)
- The storyLoop method is named in view of an expansion. The
story loop will print out the current situation for the player along
with a short list of options. It will then call character.getMove() to
get player to choose a move. The storyLoop method will then print out
the new situation and then exit.
- The Game class is the clue that holds everything together.
- _character is the partial implementation of the composition relationship with the player class
- _plot is the partial implementation of the composition relationship with the Story class
- main is the entry point into the program. In this method you should create a Game object and call startStory on that object.
- startStory is the method which will invoke the storyLoop method on _plot passint _character as a parameter.
- Note that there is no constructor listed here, but to properly implement the composition relationships, you will need to add one
This is going to be a really short story. You only need to accept one move from the user and show the results of that one move.
Each lab in this class is a little more significant than the one before
it. You are once again working with a lot of new concepts. Please allow
for sufficient time to work on this lab (expect it to take about 12
hours over the week and a half or so that you have to work on it for
those of you who are learning programming for the first time.)
When you submit this time, add a readme.txt file to your lab4 folder
that you are building. The
readme should contain:
Once you have the readme done, cd into your parent folder, zip up the
entire lab4 folder using the -r flag as you have learned in the last
few labs, and use the online submission program to submit it to me.
- Your name.
- A very brief summary of what you did, including any new methods you added and why you chose to implement things the way you did.
- A quick summary of your game/story and what I should expect it to say.
- A list of any problems still in your code or anything that you didn't get done.