-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTicTacGameBoard.java
75 lines (68 loc) · 2.02 KB
/
TicTacGameBoard.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 wheels.users.*;
import java.awt.Color;
public class TicTacGameBoard extends Frame{
private Line _top, _bottom, _left, _right;
private TicTacBoard infoBoard;
private Sensor s1,s2,s3,s4,s5,s6,s7,s8,s9;
public TicTacGameBoard(){
infoBoard = new TicTacBoard();
s1 = new Sensor(infoBoard,125,25,0,0, this);
s2 = new Sensor(infoBoard,275,25,0,1, this);
s3 = new Sensor(infoBoard,425,25,0,2, this);
s4 = new Sensor(infoBoard,125,175,1,0, this);
s5 = new Sensor(infoBoard,275,175,1,1, this);
s6 = new Sensor(infoBoard,425,175,1,2, this);
s7 = new Sensor(infoBoard,125,325,2,0, this);
s8 = new Sensor(infoBoard,275,325,2,1, this);
s9 = new Sensor(infoBoard,425,325,2,2, this);
_top = new Line();
_bottom = new Line();
_left = new Line();
_right = new Line();
_top.setThickness(2);
_bottom.setThickness(2);
_left.setThickness(2);
_right.setThickness(2);
_top.setColor(Color.black);
_bottom.setColor(Color.black);
_left.setColor(Color.black);
_right.setColor(Color.black);
_top.setPoints(125,175,575,175);
_bottom.setPoints(125,325,575,325);
_left.setPoints(275,25,275,475);
_right.setPoints(425,25,425,475);
}
public TicTacBoard getBoard(){
return infoBoard;
}
public void addPiece(int x, int y){
if (x == 0 && y == 0)
s1.addPiece();
if (x == 0 && y == 1)
s2.addPiece();
if (x == 0 && y == 2)
s3.addPiece();
if (x == 1 && y == 0)
s4.addPiece();
if (x == 1 && y == 1)
s5.addPiece();
if (x == 1 && y == 2)
s6.addPiece();
if (x == 2 && y == 0)
s7.addPiece();
if (x == 2 && y == 1)
s8.addPiece();
if (x == 2 && y == 2)
s9.addPiece();
}
public void display(){
for (int r = 0; r < 3; r++){
for (int c = 0; c < 3; c++){
addPiece(r, c);
}
}
}
public static void main(String[]args){
TicTacGameBoard app = new TicTacGameBoard();
}
}