-
Notifications
You must be signed in to change notification settings - Fork 10
/
MoveInfo.java
49 lines (41 loc) · 1.21 KB
/
MoveInfo.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
49
import java.io.Serializable;
public class MoveInfo implements Serializable
{
int oldX;
int newX;
int oldY;
int newY;
public MoveInfo()
{
oldX = 0;
oldY = 0;
newX = 1;
newY = 1;
}
public MoveInfo(int oldX, int oldY, int newX, int newY)
{
this.oldX = oldX;
this.oldY = oldY;
this.newX = newX;
this.newY = newY;
}
public String toString()
{
return (getCharLabel(oldX+1) + (oldY+1) + " to " + getCharLabel(newX+1) + (newY+1));
}
public int getOldX(){return this.oldX;}
public int getOldY(){return this.oldY;}
public int getNewX(){return this.newX;}
public int getNewY(){return this.newY;}
public void setOldX(int oldX){this.oldX = oldX;}
public void setOldY(int oldY){this.oldY = oldY;}
public void setNewX(int newX){this.newX = newX;}
public void setNewY(int newX){this.newY = newX;}
public int getGapX(){return this.newX - this.oldX;}
public int getGapY(){return this.newY - this.oldY;}
// Converts x number poisition to character label
private String getCharLabel(int i)
{
return i > 0 && i < 27 ? String.valueOf((char)(i + 64)) : null;
}
}