From 40b9b4816be90ccd514f5245716ec68c9f61277d Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 21:53:35 +0100 Subject: Add the eat command --- src/esieequest/CommandWords.java | 2 +- src/esieequest/Game.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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; */ public class CommandWords { // a constant array that holds all valid command words - private static final String[] sValidCommands = { "go", "quit", "help", "look" }; + private static final String[] sValidCommands = { "go", "quit", "help", "look", "eat" }; /** * 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 { System.out.println(aCurrentRoom.getLongDescription()); } + private void eat() { + System.out.println("You have eaten now and you are not hungry any more."); + } + /** * "Quit" was entered. Check the rest of the command to see whether we * really quit the game. @@ -256,6 +260,9 @@ public class Game { case "look": this.look(); return false; + case "eat": + this.eat(); + return false; case "help": this.printHelp(); return false; -- cgit v1.2.3