Repository navigation
Expand file tree
/
Copy pathBoard.java
More file actions
88 lines (68 loc) · 1.62 KB
/
Copy pathBoard.java
File metadata and controls
88 lines (68 loc) · 1.62 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package edu.cpp.cs.cs141.final_prog_assignment;
import java.util.Random;
public class Board {
private final int horizontal = 9;
private final int vertical = 9;
private Square[][] room = new Square[vertical][horizontal];
private Random random = new Random();
private int[] briefcaseX = {1,4,7};
private int[] briefcaseY = {1,4,7};
/**
* Creates board with room and briefcase.
*/
Board() {
createBoard();
}
/**
* Creates board with room and briefcase.
*/
public void createBoard() {
int i = briefcaseX[random.nextInt(3)];
int j = briefcaseY[random.nextInt(3)];
for(int x=0;x<horizontal;x++) {
for(int y=0;y<vertical;y++) {
if((y==1 || y==4 || y==7) && (x==1 || x==4 || x==7)) {
if(x == i && y == j) {
room[x][y] = new Square(); //with briefcase
room[x][y].setRoom();
room[x][y].briefExist();
}
else {
room[x][y] = new Square();//without briefcase
room[x][y].setRoom();
}
}
else
room[x][y] = new Square();
}
}
}
/**
*
*/
public String displayBoard(int x, int y) {
return room[x][y].display();
}
public String show(int x, int y) {
return room[x][y].reveal();
}
public Square at(int x, int y) {
return room[x][y];
}
public void set(Character player, int x, int y) {
room[x][y].setCharacter(player);
player.setX(x);
player.setY(y);
}
public void move(int x, int y) {
room[x][y].playerMoved();
}
public void setNinja(Character player, int x, int y) {
room[x][y].setNinja(player);
player.setX(x);
player.setY(y);
}
public void set(Item radar, int x, int y) {
room[x][y].setItem(radar);
}
}