-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPieces.java
More file actions
65 lines (53 loc) · 2.46 KB
/
Pieces.java
File metadata and controls
65 lines (53 loc) · 2.46 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
// The class is used to define how pawns work
class Pieces {
int row;
int column;
String chessPiece;
// The instance variable below is used to check if the chess piece that is in question is dead or not.
boolean dead = false;
String[][] chessBoard;
String[] AIPieces = {"|PA|", "|PB|", "|PC|", "|PD|", "|PE|", "|PF|", "|PG|", "|PH|",
"|R3|", "|R4|",
"|B3|", "|B4|",
"|K3|", "|K4|",
"|Q2|", "|Ki|"};
String[] playerPieces = {"|P1|", "|P2|", "|P3|", "|P4|", "|P5|", "|P6|", "|P7|", "|P8|",
"|R1|", "|R2|",
"|B1|", "|B2|",
"|K1|", "|K2|",
"|Q1|", "|KI|"};
String[] Setters = {" ", "Col1", "Col2", "Col3", "Col4", "Col5", "Col6", "Col7", "Col8",
"Row1", "Row2", "Row3", "Row4", "Row5", "Row6", "Row7", "Row8"};
// The function is used to assign the rows to the chessboard, by changing the instance variable in the class.
public void rowAssignment(int rowNow) {
this.row = rowNow;
}
// The function is used to assign the columns to the chessboard, by changing the instance variable in the class.
public void columnAssignment(int columnNow) {
this.column = columnNow;
}
// The function is used to assign the array containing the chessboard, by changing the instance variable in the class.
public void chessBoardAssignemnt(String[][] chessBoardToAssign) {
this.chessBoard = chessBoardToAssign;
}
// The function is used to assign the chess piece to the chessboard, by changing the instance variable in the class.
public void chessPieceLook(String chessPieceToAssign) {
this.chessPiece = chessPieceToAssign;
}
// The function is used as a skeleton structure for the allowed moves that the chess pieces are able to do.
// The returned value of the function is then used to see if the move that the uesr inputted is valid or not.
public boolean allowedMoves(int newRow, int newColumn) {
if ((newRow == (this.row + 1)) && (newColumn == column)) {
return true;
} else {
return false;
}
}
// The function below is used to re-assign the value in the Array[][] with the piece using the instance variables in the class.
public void setSpace(int newRow, int newColumn) {
this.chessBoard[newRow][newColumn] = this.chessPiece;
}
public String pieceReturn() {
return this.chessPiece;
}
}