aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/esieequest/Game.java16
-rw-r--r--src/esieequest/Room.java24
2 files changed, 25 insertions, 15 deletions
diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java
index 95eaa4a..a00d901 100644
--- a/src/esieequest/Game.java
+++ b/src/esieequest/Game.java
@@ -145,21 +145,7 @@ public class Game {
145 145
146 private void printLocationInfo() { 146 private void printLocationInfo() {
147 System.out.println("You are now " + this.aCurrentRoom.getDescription() + "."); 147 System.out.println("You are now " + this.aCurrentRoom.getDescription() + ".");
148 148 System.out.println(this.aCurrentRoom.getExitString());
149 System.out.print("Available exits:");
150 if (this.aCurrentRoom.aNorthExit != null) {
151 System.out.print(" North");
152 }
153 if (this.aCurrentRoom.aSouthExit != null) {
154 System.out.print(" South");
155 }
156 if (this.aCurrentRoom.aEastExit != null) {
157 System.out.print(" East");
158 }
159 if (this.aCurrentRoom.aWestExit != null) {
160 System.out.print(" West");
161 }
162 System.out.println(".");
163 } 149 }
164 150
165 private void printWelcome() { 151 private void printWelcome() {
diff --git a/src/esieequest/Room.java b/src/esieequest/Room.java
index d9235cf..5b4dcfa 100644
--- a/src/esieequest/Room.java
+++ b/src/esieequest/Room.java
@@ -47,4 +47,28 @@ public class Room {
47 } 47 }
48 return null; 48 return null;
49 } 49 }
50
51 /**
52 * Return a description of the room’s exits, for example,
53 * "Exits: north west".
54 *
55 * @return A description of the available exits.
56 */
57 public String getExitString() {
58 String vExitsString = "Available exits:";
59 if (this.aNorthExit != null) {
60 vExitsString += " North";
61 }
62 if (this.aSouthExit != null) {
63 vExitsString += " South";
64 }
65 if (this.aEastExit != null) {
66 vExitsString += " East";
67 }
68 if (this.aWestExit != null) {
69 vExitsString += " West";
70 }
71 vExitsString += ".";
72 return vExitsString;
73 }
50} 74}