I need help with JAVA (Zuul game) PLEASE?

Question by lancearmstrong1313: I need help with JAVA (Zuul game) PLEASE?
I am trying to make a method that returns a player to the previous room they were in (unless they have not moved from the start of the game in which there is no previous room to go to). This method is called back().

Here is the method code I have thus far: (I will only include the relevant stuff)

public class Game
{
private Parser parser;
private Room currentRoom, previousRoom;
.
.
.
private boolean processCommand(Command command)
{
boolean wantToQuit = false;

if(command.isUnknown()) {
System.out.println(“I don’t know what you mean…”);
return false;
}

String commandWord = command.getCommandWord();
if (commandWord.equals(“help”))
printHelp();
else if (commandWord.equals(“go”))
goRoom(command);
else if (commandWord.equals(“look”))
look();
else if (commandWord.equals(“back”))
back(command);
else if (commandWord.equals(“quit”))
wantToQuit = quit(command);

return wantToQuit;
.
.
.
private void back(Command command)
{

if(previousRoom == null) {
System.out.println(“Sorry, cannot go back…”);
return;
}
if(command.hasSecondWord()) {
// if there is a second word, we cannot go back…
System.out.println(“I don’t know what you mean…”);
return;
}

currentRoom = previousRoom; //change location to the previous room
//print method where you are
System.out.println(currentRoom.getLongDescription());
}

Can anybody help me? When I run this code, the only thing that prints is the “Sorry, cannot go back….”

I’m not sure what else to do.

Best answer:

Answer by Leon Cycles
Hmm..maybe this will give you a couple idea’s? http://marciangel.braincode.hop.clickbank.net?tid=marciangel

Know better? Leave your own answer in the comments!