-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRook.java
More file actions
44 lines (42 loc) · 955 Bytes
/
Copy pathRook.java
File metadata and controls
44 lines (42 loc) · 955 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
44
import java.awt.Color;
import java.util.*;
/**
* Represents a rook in chess.
*
* @author Linda Zeng
* @version 4.9.23
*/
public class Rook extends Piece
{
/**
* Constructs a rook
* with given color and filename.
* It is valued at 5
*
* @param col color of rook
* @param fileName file with image of rook
*/
public Rook(Color col, String filename)
{
super(col, filename, 5);
}
/**
* Indicates which locations
* the rook can move to.
* Can move up and down
* and left and right.
*
* @return an ArrayList of
* locations this can
* move to
*/
public ArrayList<Location> destinations()
{
ArrayList<Location> res = new ArrayList<Location>();
sweep(res, Location.NORTH);
sweep(res, Location.SOUTH);
sweep(res, Location.WEST);
sweep(res, Location.EAST);
return res;
}
}