-
Notifications
You must be signed in to change notification settings - Fork 513
Expand file tree
/
Copy pathChessBoard.java
More file actions
61 lines (52 loc) · 1.59 KB
/
Copy pathChessBoard.java
File metadata and controls
61 lines (52 loc) · 1.59 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
package Entities;
import Entities.PeiceType.*;
public class ChessBoard {
private Peice[][] board;
public ChessBoard(){
this.board = new Peice[8][8];
initialiseBoard();
}
public void initialiseBoard(){
board[0][0]=new Rook(false,"BR");
board[0][1]=new Knight(false,"BN");
board[0][2]=new Bishop(false,"BB");
board[0][3]=new Queen(false,"BQ");
board[0][4]=new King(false,"BK");
board[0][5]=new Bishop(false,"BB");
board[0][6]=new Knight(false,"BN");
board[0][7]=new Rook(false,"BR");
for(int j=0;j<8;j++){
board[1][j]=new Pawn(false,"BP");
}
board[7][0]=new Rook(true,"WR");
board[7][1]=new Knight(true,"WN");
board[7][2]=new Bishop(true,"WB");
board[7][3]=new Queen(true,"WQ");
board[7][4]=new King(true,"WK");
board[7][5]=new Bishop(true,"WB");
board[7][6]=new Knight(true,"WN");
board[7][7]=new Rook(true,"WR");
for(int j=0;j<8;j++){
board[6][j]=new Pawn(true,"WP");
}
}
public Peice getPeice(int i,int j){
return board[i][j];
}
public void setPeice(int i,int j,Peice p){
board[i][j]=p;
}
public void showBoard(){
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
if(board[i][j]==null){
System.out.print("-- ");
}else {
System.out.print(board[i][j].getName() + " ");
}
}
System.out.println();
}
System.out.println();
}
}