-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoom.java
More file actions
36 lines (29 loc) · 677 Bytes
/
Copy pathRoom.java
File metadata and controls
36 lines (29 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package castle;
import java.util.HashMap;
public class Room {
private String description;
// 构造框架
private HashMap<String, Room> exits = new HashMap<String, Room>();
public Room(String description) {
this.description = description;
}
/* 不是一次性输入房间所有方向 */
public void setExit(String dir, Room room) {
exits.put(dir, room);
}
@Override
public String toString() {
return description;
}
public String getExitDesc() {
StringBuffer sb = new StringBuffer();
for (String dir : exits.keySet()) {
sb.append(dir);
sb.append(' ');
}
return sb.toString();
}
public Room getExit(String direction) {
return exits.get(direction);
}
}