-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWorld.java
More file actions
44 lines (38 loc) · 996 Bytes
/
World.java
File metadata and controls
44 lines (38 loc) · 996 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
37
38
39
40
41
42
43
44
/** Creates a World object that manages the room the Player is in
*
*/
public class World {
private int room = 1;
private static World theInstance;
/** A singleton that creates a single instance of World
*
* @return the instance of the World
*/
public static synchronized World instance() {
if (theInstance == null) {
theInstance = new World();
}
return theInstance;
}
private World() {
}
//used when the player needs to be moved to the next floor
/** Updates the room the player is on when they access a warp
*
* @return the new room that the player is on
*/
public int roomUpdate(){
room++;
return room;
}
/** Returns the room that the player is in
*
* @return the number of the room that the player is located in
*/
public int getRoom() {
return room;
}
public void setRoom(int room) {
this.room = room;
}
}