Preparation
Do the following before starting this project:
Objectives
After completing this project, you should be able to:
- develop an application with several interacting classes
Project Specification
Getting Started
Warning, this project is quite challenging. You can not afford to wait until the last day to get started. Instead, strive to complete smaller chunks along the way.
- Complete all exercises in the accompanying lab assignment. This includes designing the objective and a map of the game environment.
- It is essential to provide appropriate feedback to the player as the game progresses. Strive for appropriate responses to every conceivable situation based on what the player types.
Game class
- add the look command as described in section 7.9
Parser and CommandWord classes
Improve the cohesion of the Parser and CommandWords classes.
- public String getCommandList ( ) - this method should be added to both the Parser and CommandWords classes as described in sections 7.9 and 7.10. The Game class will no longer be responsible for listing the valid commands.
Thing class
Create a new class called Thing that contains three instance variables: name (String), description (String) and a weight (int).
- create a constructor that is passed the three values
- implement set and get methods for each instance variable
Room class
Make the following changes to the Room class.
- add an instance variable of type Thing
- public Thing getThing ( ) - return a reference to the thing in the room but the Thing remains there
- public void setThing (Thing i) - add a thing to the room
- public void removeThing( ) - remove the thing in the room
- update the getLongDescription ( ) method to include the thing's description if present. "You see a thing".
More Game class
Make the following additional enhancements to the Game class.
- add an ArrayList of Things as an instance variable and instantiate it in the constructor.
- add a grab command. If the current room contains a Thing then the player picks it up. The Thing is removed from the room and added to the player's ArrayList. Appropriate messages are displayed if 1) nothing is here, 2) if the thing is too heavy to carry (a weight greater than 100), or 3) if the thing is successfully picked up such as "You are holding a dusty old book".
- add a release thing command. The player may release a thing into the current room if there is nothing currently there. The Thing is removed from the player's ArrayList and added to the room. Display appropriate messages if 1) the room already has something, 2) if the player is not holding the specified thing, or 3) if the thing is successfully dropped in the room.
- add a list command that lists all the player's things, if any.
- private void checkForWin ( ) - determine if the player has won the game. If so, print an appropriate message.
- add two commands of your choice that make sense for your game
- add a charge beamer command. A charged beamer remembers the current room. Display appropriate messages if the player attempts to charge something other than a beamer such as "You can't charge an item". Provide confirmation if the beamer is correctly charged.
- add a fire beamer command. The player is magically transformed back to the room stored in the beamer. Display appropriate messages if successful or if the beamer is not currently charged.
- public static void main(String [ ] args) - described in section 7.15. Instantiate a Game class and call the play( ) method. This method will only have two lines of code! If done correctly, it will allow you to start the game from the command line.
Sample Output
Here is a series of possible commands. Note the use of error messages and confirmations of successful actions. Your responses should be similar.
Welcome to the World of Zuul!
World of Zuul is a new, incredibly boring adventure game.
Type 'help' if you need help.
You are outside the main entrance of the university
You see a red Nike shoe
Exits: west inside south
> go west
You are in the campus pub
Exits: up
> go
Go where?
> go out
There is no door!
>grab
There is nothing to grab.
> go up
You are outside the main entrance of the university
You see a red Nike shoe
Exits: west inside south
>grab
You are holding a red Nike shoe
>list
You are holding:
a red Nike shoe
> drink
I don't understand...
> quit
Thank you for playing. Good bye.
Bonus Challenges
If you finish the project early, you may want to attempt some of the
following additional challenges.
- Implement the back command so that using it repeatedly takes the player back several rooms, all the way back to the start of the game if desired. Learn about the java Stack class to help with this. (3 pts)
Grading Criteria
This project is worth a possible 100 points.
- Stapled cover page with your name and signed pledge (- 10
pts if missing)
- Instructions for your game (-5 pts if missing)
- The code compiles (- 10 pts if it does not)
- Each method does what it is supposed to do (80 pts)
- Source code follows our Java Style
Guide (10 pts)
- Appropriate documentation including javadoc tags (10 pts)
Cover Page
Your project must have a cover page that includes your name, a title,
an appropriate picture and the following signed pledge. "I pledge
that this work is entirely mine, and mine alone (except for any code
provided by my instructor). "
Instructions for Your Game
Briefly, explain what has to be done for the player to win. Provide step by step instructions for a player to win the game. This will help during grading. For example:
- go east
- take
- go north
- go north
- drop banana
Late Policy
Projects are expected to be turned in on time. However, you are encouraged to complete a project even if you must turn it in late.
- 1 weekday late (-20 pts)
- every subsequent weekday is an additional -10 pts
- Saturday and Sunday are free days
|