forked from 1nn0vatrix/Project_Account
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChessBoard_Alternative.java
More file actions
164 lines (145 loc) · 4.22 KB
/
ChessBoard_Alternative.java
File metadata and controls
164 lines (145 loc) · 4.22 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package chessgame;
/**
*
* @author Anya, Joe and Jenna
*/
public class ChessBoard {
private String[][]board=new String[8][8];
private ChessPiece[]white = new ChessPiece[16];
private ChessPiece[]black = new ChessPiece[16];
public ChessBoard()
{
white[0]=new Rook(Color.white);
white[1]=new Knight(Color.white);
white[2]=new Bishop(Color.white);
white[3]=new Queen(Color.white);
white[4]=new King(Color.white);
white[5]=new Bishop(Color.white);
white[6]=new Knight(Color.white);
white[7]=new Rook(Color.white);
white[8]=new Pawn(Color.white);
white[9]=new Pawn(Color.white);
white[10]=new Pawn(Color.white);
white[11]=new Pawn(Color.white);
white[12]=new Pawn(Color.white);
white[13]=new Pawn(Color.white);
white[14]=new Pawn(Color.white);
white[15]=new Pawn(Color.white);
black[0]=new Rook(Color.black);
black[1]=new Knight(Color.black);
black[2]=new Bishop(Color.black);
black[3]=new Queen(Color.black);
black[4]=new King(Color.black);
black[5]=new Bishop(Color.black);
black[6]=new Knight(Color.black);
black[7]=new Rook(Color.black);
black[8]=new Pawn(Color.black);
black[9]=new Pawn(Color.black);
black[10]=new Pawn(Color.black);
black[11]=new Pawn(Color.black);
black[12]=new Pawn(Color.black);
black[13]=new Pawn(Color.black);
black[14]=new Pawn(Color.black);
black[15]=new Pawn(Color.black);
board[0][0]="A1";
board[0][1]="A2";
board[0][2]="A3";
board[0][3]="A4";
board[0][4]="A5";
board[0][5]="A6";
board[0][6]="A7";
board[0][7]="A8";
board[1][0]="B1";
board[1][1]="B2";
board[1][2]="B3";
board[1][3]="B4";
board[1][4]="B5";
board[1][5]="B6";
board[1][6]="B7";
board[1][7]="B8";
board[2][0]="C1";
board[2][1]="C2";
board[2][2]="C3";
board[2][3]="C4";
board[2][4]="C5";
board[2][5]="C6";
board[2][6]="C7";
board[2][7]="C8";
board[3][0]="D1";
board[3][1]="D2";
board[3][2]="D3";
board[3][3]="D4";
board[3][4]="D5";
board[3][5]="D6";
board[3][6]="D7";
board[3][7]="D8";
board[4][0]="E1";
board[4][1]="E2";
board[4][2]="E3";
board[4][3]="E4";
board[4][4]="E5";
board[4][5]="E6";
board[4][6]="E7";
board[4][7]="E8";
board[5][0]="F1";
board[5][1]="F2";
board[5][2]="F3";
board[5][3]="F4";
board[5][4]="F5";
board[5][5]="F6";
board[5][6]="F7";
board[5][7]="F8";
board[6][0]="G1";
board[6][1]="G2";
board[6][2]="G3";
board[6][3]="G4";
board[6][4]="G5";
board[6][5]="G6";
board[6][6]="G7";
board[6][7]="G8";
board[7][0]="H1";
board[7][1]="H2";
board[7][2]="H3";
board[7][3]="H4";
board[7][4]="H5";
board[7][5]="H6";
board[7][6]="H7";
board[7][7]="H8";
/* int count = 0;
for(int i=0; i<board.length; i++)
{
for(int j = 0; j<8; j++)
{
if(i==0||i==1)
{
board[i][j]=black[count];
count++;
}
if(i==6||i==7)
{
board[i][j].equals(white[count]);
count++;
}
else
{
board[i][j]=null;
count=0;
}
}
}*/
}
public String printBoard()
{ String tmp="";
for(int i =0; i<8; i++)
{
tmp+="\n\n\n\n";
for(int j=0; j<8; j++)
{
tmp+=("|\t"+board[i][j]+"\t");
if(j==7)
tmp+="|";
}
}
return tmp;
}
}