-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeleporter.java
More file actions
35 lines (31 loc) · 787 Bytes
/
Teleporter.java
File metadata and controls
35 lines (31 loc) · 787 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
import java.util.Random;
import java.util.ArrayList;
/**
* A room that teleports you to a random room.
*
* @author Thomas Vakili
* @version 2013.12.12
*/
public class Teleporter extends Room {
private Room destination;
private ArrayList<Room> rooms;
private Random rand;
public Teleporter(ArrayList<Room> rooms) {
super("at a teleporter. Wonder where it leads...");
rand = new Random();
this.rooms = rooms;
randomizeDestination();
}
/**
* Generate a random destination.
*/
public void randomizeDestination() {
destination = rooms.get(rand.nextInt(rooms.size()));
}
/**
* Returns the teleporters destination.
*/
public Room getDestination() {
return destination;
}
}