aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-02-23 21:53:35 +0100
committerPacien TRAN-GIRARD2014-02-23 21:53:35 +0100
commit40b9b4816be90ccd514f5245716ec68c9f61277d (patch)
tree839473e3812e5b9f57f7041daee9a5467e99b88c
parent76ace5863f2d355edae3d0d793f0dc8dbc9fa5b7 (diff)
downloadesieequest-40b9b4816be90ccd514f5245716ec68c9f61277d.tar.gz
Add the eat command
-rw-r--r--src/esieequest/CommandWords.java2
-rw-r--r--src/esieequest/Game.java7
2 files changed, 8 insertions, 1 deletions
diff --git a/src/esieequest/CommandWords.java b/src/esieequest/CommandWords.java
index 315fc0d..3d8855d 100644
--- a/src/esieequest/CommandWords.java
+++ b/src/esieequest/CommandWords.java
@@ -12,7 +12,7 @@ package esieequest;
12 */ 12 */
13public class CommandWords { 13public 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", "look" }; 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 5fc2813..350fa15 100644
--- a/src/esieequest/Game.java
+++ b/src/esieequest/Game.java
@@ -226,6 +226,10 @@ public class Game {
226 System.out.println(aCurrentRoom.getLongDescription()); 226 System.out.println(aCurrentRoom.getLongDescription());
227 } 227 }
228 228
229 private void eat() {
230 System.out.println("You have eaten now and you are not hungry any more.");
231 }
232
229 /** 233 /**
230 * "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
231 * really quit the game. 235 * really quit the game.
@@ -256,6 +260,9 @@ public class Game {
256 case "look": 260 case "look":
257 this.look(); 261 this.look();
258 return false; 262 return false;
263 case "eat":
264 this.eat();
265 return false;
259 case "help": 266 case "help":
260 this.printHelp(); 267 this.printHelp();
261 return false; 268 return false;