aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/esieequest/Game.java3
-rw-r--r--src/esieequest/Room.java44
2 files changed, 22 insertions, 25 deletions
diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java
index 1be4d15..bad0106 100644
--- a/src/esieequest/Game.java
+++ b/src/esieequest/Game.java
@@ -180,8 +180,7 @@ public class Game {
180 } 180 }
181 181
182 private void printLocationInfo() { 182 private void printLocationInfo() {
183 System.out.println("You are now " + this.aCurrentRoom.getDescription() + "."); 183 System.out.println(this.aCurrentRoom.getLongDescription());
184 System.out.println(this.aCurrentRoom.getExitString());
185 } 184 }
186 185
187 private void printWelcome() { 186 private void printWelcome() {
diff --git a/src/esieequest/Room.java b/src/esieequest/Room.java
index 1b23afa..9d7f071 100644
--- a/src/esieequest/Room.java
+++ b/src/esieequest/Room.java
@@ -1,6 +1,7 @@
1package esieequest; 1package esieequest;
2 2
3import java.util.HashMap; 3import java.util.HashMap;
4import java.util.Set;
4 5
5/** 6/**
6 * A room. 7 * A room.
@@ -25,8 +26,19 @@ public class Room {
25 26
26 } 27 }
27 28
28 public String getDescription() { 29 /**
29 return this.aDescription; 30 * Return a long description of this room, of the form:
31 *
32 * You are in the kitchen.
33 *
34 * Exits: north west
35 *
36 * @return A description of the room, including exits.
37 */
38 public String getLongDescription() {
39 String vLongDescription = "You are now " + this.aDescription + ".\n";
40 vLongDescription += getExitString();
41 return vLongDescription;
30 } 42 }
31 43
32 /** 44 /**
@@ -50,33 +62,19 @@ public class Room {
50 } 62 }
51 63
52 /** 64 /**
53 * Return a description of the room’s exits, for example, 65 * Return a description of the room’s exits, for example
54 * "Exits: north west". 66 * "Exits: north west".
55 * 67 *
56 * @return A description of the available exits. 68 * @return A description of the available exits.
57 */ 69 */
58 public String getExitString() { 70 public String getExitString() {
59 String vExitsString = "Available exits:"; 71 String vExitString = "Available exits:";
60 if (this.aExits.get("north") != null) { 72 Set<String> keys = this.aExits.keySet();
61 vExitsString += " north"; 73 for (String exit : keys) {
62 } 74 vExitString += " " + exit;
63 if (this.aExits.get("south") != null) {
64 vExitsString += " south";
65 }
66 if (this.aExits.get("east") != null) {
67 vExitsString += " east";
68 }
69 if (this.aExits.get("west") != null) {
70 vExitsString += " west";
71 }
72 if (this.aExits.get("up") != null) {
73 vExitsString += " up";
74 }
75 if (this.aExits.get("down") != null) {
76 vExitsString += " down";
77 } 75 }
78 vExitsString += "."; 76 vExitString += ".";
79 return vExitsString; 77 return vExitString;
80 } 78 }
81 79
82} 80}