From 5f1d0ada248764beda05dee2695bab802eeadcd6 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 23 Feb 2014 22:44:26 +0100 Subject: Change command list printing --- src/esieequest/CommandWords.java | 7 ++++--- src/esieequest/Game.java | 2 +- src/esieequest/Parser.java | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/esieequest/CommandWords.java b/src/esieequest/CommandWords.java index a0718e3..c942043 100644 --- a/src/esieequest/CommandWords.java +++ b/src/esieequest/CommandWords.java @@ -35,10 +35,11 @@ public class CommandWords { /** * Print all valid commands to System.out. */ - public void showAll() { + public String getCommandList() { + String vCommands = ""; for (String vCommand : this.sValidCommands) { - System.out.print(vCommand + " "); + vCommands += " " + vCommand; } - System.out.println(); + return vCommands; } } diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index 165724a..cae7559 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java @@ -215,7 +215,7 @@ public class Game { System.out.println("You wander around at the university."); System.out.println(""); System.out.println("Your command words are:"); - this.aParser.showCommands(); + System.out.println(this.aParser.showCommands()); } private void look() { diff --git a/src/esieequest/Parser.java b/src/esieequest/Parser.java index b8f5c94..d270f1e 100644 --- a/src/esieequest/Parser.java +++ b/src/esieequest/Parser.java @@ -59,7 +59,7 @@ public class Parser { /** * Print out a list of valid command words. */ - public void showCommands() { - this.aValidCommands.showAll(); + public String showCommands() { + return this.aValidCommands.getCommandList(); } } -- cgit v1.2.3