-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTile.java
More file actions
43 lines (34 loc) · 884 Bytes
/
Copy pathTile.java
File metadata and controls
43 lines (34 loc) · 884 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
public abstract class Tile {
private char symbol;
private Tile north = SENTINEL, south = SENTINEL, east = SENTINEL, west = SENTINEL;
Tile getNorth() {return north;}
Tile getEast() {return east;}
Tile getSouth() {return south;}
Tile getWest() {return west;}
public Tile(char c) {
this.symbol = c;
}
@Override
public String toString() {
return symbol+"";
}
public void enter(Player p) throws GameException {
throw new GameException("You can't go there!");
}
public void setAdjacent(Tile n, Tile e, Tile s, Tile w) {
north = n;
east = e;
south = s;
west = w;
}
public static Tile SENTINEL = new Sentinel();
public static class Sentinel extends Tile {
public Sentinel() {
super(' ');
}
@Override
public void enter(Player p) throws CollisionException {
throw new CollisionException("You hit the end of the world!");
}
}
}