-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLand.java
More file actions
83 lines (81 loc) · 1.47 KB
/
Copy pathLand.java
File metadata and controls
83 lines (81 loc) · 1.47 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
// Luke Jacobs
// Land
// 2D array of plots
import java.util.*;
public class Land
{
private Agriculture[][] land;
public Land()
{
land = new Agriculture[5][5];
land[0][0] = new Agriculture();
land[0][1] = new Agriculture();
land[1][0] = new Agriculture();
land[1][1] = new Agriculture();
land[0][2] = new Agriculture();
land[1][2] = new Agriculture();
}
public void addPlot()//doesn't work
{
int row = 0;
int col = 0;
boolean done = false;
for(int r = 0;r < land.length;r++)
{
for(int c = 0;c < land[r].length;c++)
{
if(land[r][c] == null && done == false)
{
row = r;
col = c;
land[row][col] = new Agriculture();
done = true;
}
}
}
}
public void placeItem(Agriculture a,int i,int k)
{
for(int r = 0;r < land.length;r++)
{
for(int c = 0;c < land[r].length;c++)
{
if( r == i && c == k)
{
land[r][c] = a;
}
}
}
}
public Agriculture getPlot(int x,int y)
{
for(int r = 0;r < land.length;r++)
{
for(int c = 0;c < land[r].length;c++)
{
if(r == x && c == y)
{
return land[r][c];
}
}
}
return new Agriculture();
}
public Agriculture[][] getLand()
{
return land;
}
public void setPlot(int x,int y,Agriculture a)
{
for(int r = 0;r < land.length;r++)
{
for(int c = 0;c < land[r].length;c++)
{
if(r == x && c == y)
{
land[r][c] = a;
}
}
}
}
}