zuul5
This commit is contained in:
@@ -15,7 +15,7 @@ public class CommandWords
|
||||
{
|
||||
// a constant array that holds all valid command words
|
||||
private static final String[] validCommands = {
|
||||
"go", "quit", "help"
|
||||
"go", "quit", "help", "look"
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -40,4 +40,14 @@ public class CommandWords
|
||||
// if we get here, the string was not found in the commands
|
||||
return false;
|
||||
}
|
||||
public String showAll()
|
||||
{
|
||||
StringBuilder exitsInString = new StringBuilder();
|
||||
|
||||
for (String validCommands : validCommands){
|
||||
exitsInString.append(validCommands).append(" ");
|
||||
}
|
||||
|
||||
return exitsInString.toString().trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +145,9 @@ public class Game
|
||||
else if (commandWord.equals("quit")) {
|
||||
wantToQuit = quit(command);
|
||||
}
|
||||
else if (commandWord.equals("look")) {
|
||||
look(currentRoom);
|
||||
}
|
||||
|
||||
return wantToQuit;
|
||||
}
|
||||
@@ -162,7 +165,7 @@ public class Game
|
||||
System.out.println("through the jungle. At once there is a glade. On it there a buildings...");
|
||||
System.out.println();
|
||||
System.out.println("Your command words are:");
|
||||
System.out.println(" go quit help");
|
||||
System.out.println(parser.showCommands());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,4 +216,8 @@ public class Game
|
||||
System.out.print(currentRoom.getLongDescription());
|
||||
System.out.println();
|
||||
}
|
||||
private void look(Room currentRoom)
|
||||
{
|
||||
System.out.println(currentRoom.getLongDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,4 +64,8 @@ public class Parser
|
||||
return new Command(null, word2);
|
||||
}
|
||||
}
|
||||
public String showCommands()
|
||||
{
|
||||
return commands.showAll();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user