aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/Room.java
blob: 5b4dcfafe7a296b2b43d08b429a14428e47b6977 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package esieequest;

/**
 * A room.
 * 
 * @author Pacien TRAN-GIRARD
 * @author Benoit LUBRANO DI SBARAGLIONE
 * 
 * @version February 2014
 */
public class Room {
	private String aDescription;

	private Room aNorthExit;
	private Room aSouthExit;
	private Room aEastExit;
	private Room aWestExit;

	public Room(final String pDescription) {
		this.aDescription = pDescription;
	}

	public String getDescription() {
		return this.aDescription;
	}

	/**
	 * Defines the four exits (other rooms) of this room.
	 */
	public void setExits(final Room pNorthExit, final Room pWestExit, final Room pSouthExit, final Room pEastExit) {
		this.aNorthExit = pNorthExit;
		this.aSouthExit = pSouthExit;
		this.aEastExit = pEastExit;
		this.aWestExit = pWestExit;
	}

	public Room getExit(String pDirection) {
		switch (pDirection) {
		case "north":
			return this.aNorthExit;
		case "south":
			return this.aSouthExit;
		case "east":
			return this.aEastExit;
		case "west":
			return this.aWestExit;
		}
		return null;
	}

	/**
	 * Return a description of the room’s exits, for example,
	 * "Exits: north west".
	 * 
	 * @return A description of the available exits.
	 */
	public String getExitString() {
		String vExitsString = "Available exits:";
		if (this.aNorthExit != null) {
			vExitsString += " North";
		}
		if (this.aSouthExit != null) {
			vExitsString += " South";
		}
		if (this.aEastExit != null) {
			vExitsString += " East";
		}
		if (this.aWestExit != null) {
			vExitsString += " West";
		}
		vExitsString += ".";
		return vExitsString;
	}
}