-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.java
More file actions
90 lines (78 loc) · 2.37 KB
/
Copy pathMap.java
File metadata and controls
90 lines (78 loc) · 2.37 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
89
public class Map{
// Private Variables
private Fish[][] lakeMap;
private int fishCol;
private int fishRow;
private boolean fishCaughtOrNot;
// Constructs lakeMap, sets up Boundaries and Accesible Areas
public Map(){
lakeMap = new Fish[52][52];
for(int row = 0 ; row < lakeMap.length ; row++)
{
for(int col = 0 ; col < lakeMap[row].length ; col++)
{
if(row == 0 || row == 51 || col == 0 || col == 51)
{
lakeMap[row][col] = new Fish("border");
}
else
{
lakeMap[row][col] = new Fish();
}
}
}
fishCol = (int)(Math.random()*49)+1;
fishRow = (int)(Math.random()*49)+1;
lakeMap[fishRow][fishCol] = new Fish("fish");
fishCaughtOrNot = false;
}
public void printMap(){
for(Fish[] row : lakeMap)
{
for(Fish col : row)
{
System.out.print(col.getCord());
}
System.out.println();
}
}
//Mutators:
public void caughtFish(){
fishCaughtOrNot = true;
}
public void setFishX(int x){
lakeMap[fishRow][fishCol] = new Fish();
fishCol = x;
lakeMap[fishRow][fishCol] = new Fish("fish");
}
public void setFishY(int y){
lakeMap[fishRow][fishCol] = new Fish();
fishRow = y;
lakeMap[fishRow][fishCol] = new Fish("fish");
}
//Returners:
public Fish[][] getMap(){
return lakeMap;
}
public int getFishX(){
return fishCol;
}
public int getFishY(){
return fishRow;
}
public boolean isFishCaught(){
return fishCaughtOrNot;
}
// Little Cheat to Reset Fish Coordinates
public void resetFish(){
int ogX = fishCol;
int ogY = fishRow;
lakeMap[fishRow][fishCol] = new Fish();
while(fishCol == ogX || fishRow == ogY)
{
fishCol = (int)(Math.random()*49)+1;
fishRow = (int)(Math.random()*49)+1;
}
lakeMap[fishRow][fishCol] = new Fish("fish");
}
}