From 698e3cd2591f6bf6f0fd21d6843ced267e0141bb Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 21:49:57 +0100 Subject: Add the look 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 3a77015..315fc0d 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" }; + private static final String[] sValidCommands = { "go", "quit", "help", "look" }; /** * Constructor - initialise the command words. diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index 638c9b8..5fc2813 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java @@ -222,6 +222,10 @@ public class Game { System.out.println(" go quit help"); } + private void look() { + System.out.println(aCurrentRoom.getLongDescription()); + } + /** * "Quit" was entered. Check the rest of the command to see whether we * really quit the game. @@ -249,6 +253,9 @@ public class Game { case "go": this.goRoom(pCommand); return false; + case "look": + this.look(); + return false; case "help": this.printHelp(); return false; -- cgit v1.2.3