-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFigure.java
More file actions
49 lines (41 loc) · 988 Bytes
/
Figure.java
File metadata and controls
49 lines (41 loc) · 988 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
45
46
47
48
49
public class Figure {
protected int x = 0;
protected int y = 0;
protected char color='N';
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public boolean move(int x, int y) {
return true;
}
protected boolean moveCross(int x, int y) {
if (this.x == x || this.y == y) {
return true;
}
return false;
}
protected boolean moveDiagonal(int x, int y) {
if (Math.abs(this.x - x) == Math.abs(this.y - y)) {
return true;
}
return false;
}
protected boolean[][] beat(int n) {
boolean[][] field = new boolean[8][8];
for(int x=0;x<n;x++) {
for(int y=0;y<n;y++) {
if (move(x, y)) {
field[x][y] = true;
}
}
}
return field;
}
@Override
public String toString() {
return "-/-";
}
}