-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock.java
More file actions
executable file
·77 lines (61 loc) · 1.54 KB
/
Block.java
File metadata and controls
executable file
·77 lines (61 loc) · 1.54 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import java.util.ArrayList;
/**
* Write a description of class Block here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Block implements Comparable <Block>
{
public int Cost;
public int rCoord;
public int cCoord;
public Block boss = null;
//public int type;
public Block()
{
Cost = 0;
}
public int getCost(){
return Cost;
}
public void setCost(int c){
this.Cost = c;
}
public void setCoord(int r, int c){
rCoord = r;
cCoord = c;
}
public String getCoords(){
return rCoord+""+cCoord;
}
public Block getBoss(){
return boss;
}
public int getRCoord(){
return rCoord;
}
public int getCCoord(){
return cCoord;
}
public Block deepCopy(Block start){
Block copy = new Block();
copy.Cost = Cost;
copy.boss = boss;
copy.rCoord = rCoord;
copy.cCoord = cCoord;
return copy;
}
public int getEuclidianDistance(Block block){
return (int) (10 * Math.sqrt((rCoord - block.rCoord)*(rCoord - block.rCoord) + (cCoord - block.cCoord)*(cCoord - block.cCoord)));
}
public int getManhattanDistance(Block block){
return (int) (10 * Math.abs(rCoord - block.rCoord) + Math.abs(cCoord - block.cCoord));
}
public int compareTo(Block other){
return Cost-other.Cost;
}
public String toString(){
return "Current Cost: " + Cost + "row: " + rCoord + "col: " + cCoord;
}
}