-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovesGenerator.java
More file actions
80 lines (67 loc) · 1.72 KB
/
MovesGenerator.java
File metadata and controls
80 lines (67 loc) · 1.72 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
import java.util.ArrayList;
import java.awt.*;
/**
* This class creates aggregate for BattleField.
*
* @author ChangSu Nam
* @UNI cn2521
* @since Assignment6 2.2
*/
public class MovesGenerator implements Draggable {
/**
* Constructor that creates aggregate for BattleField
*
*/
public MovesGenerator() {
battleFieldArrayList = new ArrayList<BattleField>();
}
/**
* Adds a battleField object to the aggregate
* @param moveToBeAdded the BattleField that will be added
*/
public void addMove(BattleField moveToBeAdded) {
battleFieldArrayList.add(moveToBeAdded);
}
/**
* Get method to get a specific BattleField.
*
* @param moveIndex the index to be retrieved.
* @return the specific BattleField stored at index
*/
public Draggable getMove(int moveIndex) {
return battleFieldArrayList.get(moveIndex);
}
/**
* This method gets the size of the aggregate.
*
* @return the size of aggregate
*/
public int getSize() {
return battleFieldArrayList.size();
}
/**
* This method draws the moves created in each battlefield in arrayList, with Graphics2D
*
* @param g2d reference to Graphics2D
*/
public void draw(Graphics2D g2d) {
for (Draggable battleFieldObject : battleFieldArrayList) {
battleFieldObject.draw(g2d);
}
}
/**
* This method changes the coordinate of the diagram.
*
* @param xChange the change to be made in x coordinate
* @param yChange the change to be made in y coordinate.
*/
public void translate(int xChange, int yChange) {
for (BattleField move : battleFieldArrayList) {
move.translate(xChange, yChange);
}
}
/**
* battleFieldArrayList the arrayList that holds battleField.
*/
static ArrayList<BattleField> battleFieldArrayList;
}