-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoveEfficiency.java
40 lines (33 loc) · 929 Bytes
/
MoveEfficiency.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
package project2048;
/**
* @author Anna S. Almielka
*/
// The class describes the efficiency of the move
public class MoveEfficiency implements Comparable<MoveEfficiency> {
private int numberOfEmptyTiles;
private int score;
private Move move;
public MoveEfficiency(int numberOfEmptyTiles, int score, Move move) {
this.numberOfEmptyTiles = numberOfEmptyTiles;
this.score = score;
this.move = move;
}
@Override
public int compareTo(MoveEfficiency o) {
if (numberOfEmptyTiles > o.numberOfEmptyTiles) {
return 1;
} else if (numberOfEmptyTiles < o.numberOfEmptyTiles) {
return -1;
} else {
if (score > o.score) {
return 1;
} else if (score < o.score) {
return -1;
}
}
return 0;
}
public Move getMove() {
return move;
}
}