-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAttackRecord.java
More file actions
43 lines (38 loc) · 839 Bytes
/
Copy pathAttackRecord.java
File metadata and controls
43 lines (38 loc) · 839 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
/**
* Keeps a record of all attacks that a player has made.
*/
public class AttackRecord {
private boolean[][] record;
public AttackRecord()
/**
* Creates a new AttackRecord.
*
* The array is 10x10.
*/
{
record = new boolean[10][10];
}
public void addAttack(Coordinates c)
/**
* Adds an attack to the array.
* The value is changed from false to true.
*
* @param c Coordinates of the attack.
*/
{
record[c.getX()][c.getY()] = true;
}
public boolean isRedundant(int x, int y)
/**
* Determines whether the attack has already been made.
*
* @param x The vertical coordinate of the attack.
* @param y The horizontal coordinate of the attack.
*
* @return record[x][y] Returns true if this location
* on the grid has already been attacked before.
*/
{
return record[x][y];
}
}