diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/esieequest/CommandWords.java | 2 | ||||
-rw-r--r-- | src/esieequest/Game.java | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/esieequest/CommandWords.java b/src/esieequest/CommandWords.java index 3a77015..3d8855d 100644 --- a/src/esieequest/CommandWords.java +++ b/src/esieequest/CommandWords.java | |||
@@ -12,7 +12,7 @@ package esieequest; | |||
12 | */ | 12 | */ |
13 | public class CommandWords { | 13 | public class CommandWords { |
14 | // a constant array that holds all valid command words | 14 | // a constant array that holds all valid command words |
15 | private static final String[] sValidCommands = { "go", "quit", "help" }; | 15 | private static final String[] sValidCommands = { "go", "quit", "help", "look", "eat" }; |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * Constructor - initialise the command words. | 18 | * Constructor - initialise the command words. |
diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index 638c9b8..350fa15 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java | |||
@@ -222,6 +222,14 @@ public class Game { | |||
222 | System.out.println(" go quit help"); | 222 | System.out.println(" go quit help"); |
223 | } | 223 | } |
224 | 224 | ||
225 | private void look() { | ||
226 | System.out.println(aCurrentRoom.getLongDescription()); | ||
227 | } | ||
228 | |||
229 | private void eat() { | ||
230 | System.out.println("You have eaten now and you are not hungry any more."); | ||
231 | } | ||
232 | |||
225 | /** | 233 | /** |
226 | * "Quit" was entered. Check the rest of the command to see whether we | 234 | * "Quit" was entered. Check the rest of the command to see whether we |
227 | * really quit the game. | 235 | * really quit the game. |
@@ -249,6 +257,12 @@ public class Game { | |||
249 | case "go": | 257 | case "go": |
250 | this.goRoom(pCommand); | 258 | this.goRoom(pCommand); |
251 | return false; | 259 | return false; |
260 | case "look": | ||
261 | this.look(); | ||
262 | return false; | ||
263 | case "eat": | ||
264 | this.eat(); | ||
265 | return false; | ||
252 | case "help": | 266 | case "help": |
253 | this.printHelp(); | 267 | this.printHelp(); |
254 | return false; | 268 | return false; |