aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/esieequest/Game.java19
-rw-r--r--src/esieequest/Room.java22
2 files changed, 19 insertions, 22 deletions
diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java
index 7da57e9..95eaa4a 100644
--- a/src/esieequest/Game.java
+++ b/src/esieequest/Game.java
@@ -132,24 +132,7 @@ public class Game {
132 return; 132 return;
133 } 133 }
134 134
135 Room vNextRoom; 135 Room vNextRoom = aCurrentRoom.getExit(pCommand.getSecondWord());
136 switch (pCommand.getSecondWord()) {
137 case "north":
138 vNextRoom = this.aCurrentRoom.aNorthExit;
139 break;
140 case "south":
141 vNextRoom = this.aCurrentRoom.aSouthExit;
142 break;
143 case "east":
144 vNextRoom = this.aCurrentRoom.aEastExit;
145 break;
146 case "west":
147 vNextRoom = this.aCurrentRoom.aWestExit;
148 break;
149 default:
150 System.out.println("Go where ?");
151 return;
152 }
153 136
154 if (vNextRoom == null) { 137 if (vNextRoom == null) {
155 System.out.println("There is no door!"); 138 System.out.println("There is no door!");
diff --git a/src/esieequest/Room.java b/src/esieequest/Room.java
index 0a16e33..d9235cf 100644
--- a/src/esieequest/Room.java
+++ b/src/esieequest/Room.java
@@ -11,10 +11,10 @@ package esieequest;
11public class Room { 11public class Room {
12 private String aDescription; 12 private String aDescription;
13 13
14 public Room aNorthExit; 14 private Room aNorthExit;
15 public Room aSouthExit; 15 private Room aSouthExit;
16 public Room aEastExit; 16 private Room aEastExit;
17 public Room aWestExit; 17 private Room aWestExit;
18 18
19 public Room(final String pDescription) { 19 public Room(final String pDescription) {
20 this.aDescription = pDescription; 20 this.aDescription = pDescription;
@@ -33,4 +33,18 @@ public class Room {
33 this.aEastExit = pEastExit; 33 this.aEastExit = pEastExit;
34 this.aWestExit = pWestExit; 34 this.aWestExit = pWestExit;
35 } 35 }
36
37 public Room getExit(String pDirection) {
38 switch (pDirection) {
39 case "north":
40 return this.aNorthExit;
41 case "south":
42 return this.aSouthExit;
43 case "east":
44 return this.aEastExit;
45 case "west":
46 return this.aWestExit;
47 }
48 return null;
49 }
36} 50}