-
Notifications
You must be signed in to change notification settings - Fork 0
/
CastleProperty.java
48 lines (48 loc) · 1.07 KB
/
CastleProperty.java
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
import java.awt.Point;
import java.util.*;
class CastleProperty
{
ArrayList<Object[]> castles=new ArrayList<>();
boolean isvalid=false;
public boolean isValid()
{
return isvalid;
}
public void bind(Point kingloc, Point newrookloc,rook therook)
{
castles.add(new Object[]{kingloc,newrookloc,therook});
isvalid=true;
}
public boolean isInPlace(Point p)
{
for(Object[] h:castles)
{
Point ps=(Point)h[0];
if(p.equals(ps))
return true;
}
return false;
}
public Object[] getCastlePropertySet(Point p)
{
for(Object[] h:castles)
{
Point ps=(Point)h[0];
if(p.equals(ps))
return h;
}
return null;
}
public rook getRookToCastleWith(Point kl)
{
for(Object[] h:castles)
{
Point ps=(Point)h[0];
if(kl.equals(ps))
{
return((rook)h[2]);
}
}
return null;//theoretically should never happen
}
}