-
Notifications
You must be signed in to change notification settings - Fork 0
/
tiles.java
75 lines (66 loc) · 1.52 KB
/
tiles.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
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
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.awt.*;
public class tiles extends JButton implements ActionListener{
tiles parent;
int col;
int row;
int gcost;// gcost is the cost between the start tile and current tile
int hcost; // hcost is the cost between the current tile and goal tile
int fcost; // fcost is the sum of hcost and gcost
boolean start ;
boolean goal;
boolean open;
boolean checked;
boolean solid;
public tiles(int col,int row)
{
this.col=col;
this.row=row;
setBackground(Color.white);
setForeground(Color.black);
addActionListener(this);
}
public void setstart(){
setBackground(Color.blue);
setForeground(Color.white);
setText("Start");
start= true;
}
public void setgoal(){
setBackground(Color.yellow);
setForeground(Color.black);
setText("Goal");
goal= true;
}
public void setsolid()
{
setBackground(Color.black);
setForeground(Color.black);
solid=true;
}
public void setopen()
{
open = true;
}
public void setchecked()
{
if(start==false && goal==false)
{
setBackground(Color.red);
setForeground(Color.black);
}
checked=true;
}
public void setpath()
{
setBackground(Color.green);
setForeground(Color.black);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
setBackground(Color.red);
}
}