Added all other pieces and moved them into a separate package
This commit is contained in:
parent
f420d4f9c2
commit
ff26346623
@ -1,6 +1,13 @@
|
|||||||
package dev.kske.chess;
|
package dev.kske.chess;
|
||||||
|
|
||||||
import dev.kske.chess.Piece.Color;
|
import dev.kske.chess.piece.Bishop;
|
||||||
|
import dev.kske.chess.piece.King;
|
||||||
|
import dev.kske.chess.piece.Knight;
|
||||||
|
import dev.kske.chess.piece.Pawn;
|
||||||
|
import dev.kske.chess.piece.Piece;
|
||||||
|
import dev.kske.chess.piece.Piece.Color;
|
||||||
|
import dev.kske.chess.piece.Queen;
|
||||||
|
import dev.kske.chess.piece.Rook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>Chess</strong><br>
|
* Project: <strong>Chess</strong><br>
|
||||||
@ -17,12 +24,41 @@ public class Board {
|
|||||||
initializeDefaultPositions();
|
initializeDefaultPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialized the board array with the default chess pieces and positions.
|
||||||
|
*/
|
||||||
private void initializeDefaultPositions() {
|
private void initializeDefaultPositions() {
|
||||||
// Initialize pawns
|
// Initialize pawns
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
boardArr[i][1] = new Pawn(Color.BLACK);
|
boardArr[i][1] = new Pawn(Color.BLACK);
|
||||||
boardArr[i][6] = new Pawn(Color.WHITE);
|
boardArr[i][6] = new Pawn(Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize kings
|
||||||
|
boardArr[4][0] = new King(Color.BLACK);
|
||||||
|
boardArr[4][7] = new King(Color.WHITE);
|
||||||
|
|
||||||
|
// Initialize queens
|
||||||
|
boardArr[3][0] = new Queen(Color.BLACK);
|
||||||
|
boardArr[3][7] = new Queen(Color.WHITE);
|
||||||
|
|
||||||
|
// Initialize rooks
|
||||||
|
boardArr[0][0] = new Rook(Color.BLACK);
|
||||||
|
boardArr[0][7] = new Rook(Color.WHITE);
|
||||||
|
boardArr[7][0] = new Rook(Color.BLACK);
|
||||||
|
boardArr[7][7] = new Rook(Color.WHITE);
|
||||||
|
|
||||||
|
// Initialize knights
|
||||||
|
boardArr[1][0] = new Knight(Color.BLACK);
|
||||||
|
boardArr[1][7] = new Knight(Color.WHITE);
|
||||||
|
boardArr[6][0] = new Knight(Color.BLACK);
|
||||||
|
boardArr[6][7] = new Knight(Color.WHITE);
|
||||||
|
|
||||||
|
// Initialize bishops
|
||||||
|
boardArr[2][0] = new Bishop(Color.BLACK);
|
||||||
|
boardArr[2][7] = new Bishop(Color.WHITE);
|
||||||
|
boardArr[5][0] = new Bishop(Color.BLACK);
|
||||||
|
boardArr[5][7] = new Bishop(Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +13,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import dev.kske.chess.piece.Piece;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>Chess</strong><br>
|
* Project: <strong>Chess</strong><br>
|
||||||
* File: <strong>BoardPanel.java</strong><br>
|
* File: <strong>BoardPanel.java</strong><br>
|
||||||
|
17
src/dev/kske/chess/piece/Bishop.java
Normal file
17
src/dev/kske/chess/piece/Bishop.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package dev.kske.chess.piece;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>Chess</strong><br>
|
||||||
|
* File: <strong>Bishop.java</strong><br>
|
||||||
|
* Created: <strong>01.07.2019</strong><br>
|
||||||
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
||||||
|
*/
|
||||||
|
public class Bishop extends Piece {
|
||||||
|
|
||||||
|
public Bishop(Color color) {
|
||||||
|
super(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getType() { return Type.BISHOP; }
|
||||||
|
}
|
17
src/dev/kske/chess/piece/King.java
Normal file
17
src/dev/kske/chess/piece/King.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package dev.kske.chess.piece;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>Chess</strong><br>
|
||||||
|
* File: <strong>King.java</strong><br>
|
||||||
|
* Created: <strong>01.07.2019</strong><br>
|
||||||
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
||||||
|
*/
|
||||||
|
public class King extends Piece {
|
||||||
|
|
||||||
|
public King(Color color) {
|
||||||
|
super(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getType() { return Type.KING; }
|
||||||
|
}
|
17
src/dev/kske/chess/piece/Knight.java
Normal file
17
src/dev/kske/chess/piece/Knight.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package dev.kske.chess.piece;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>Chess</strong><br>
|
||||||
|
* File: <strong>Knight.java</strong><br>
|
||||||
|
* Created: <strong>01.07.2019</strong><br>
|
||||||
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
||||||
|
*/
|
||||||
|
public class Knight extends Piece {
|
||||||
|
|
||||||
|
public Knight(Color color) {
|
||||||
|
super(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getType() { return Type.KNIGHT; }
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package dev.kske.chess;
|
package dev.kske.chess.piece;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>Chess</strong><br>
|
* Project: <strong>Chess</strong><br>
|
@ -1,4 +1,4 @@
|
|||||||
package dev.kske.chess;
|
package dev.kske.chess.piece;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>Chess</strong><br>
|
* Project: <strong>Chess</strong><br>
|
17
src/dev/kske/chess/piece/Queen.java
Normal file
17
src/dev/kske/chess/piece/Queen.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package dev.kske.chess.piece;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>Chess</strong><br>
|
||||||
|
* File: <strong>Queen.java</strong><br>
|
||||||
|
* Created: <strong>01.07.2019</strong><br>
|
||||||
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
||||||
|
*/
|
||||||
|
public class Queen extends Piece {
|
||||||
|
|
||||||
|
public Queen(Color color) {
|
||||||
|
super(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getType() { return Type.QUEEN; }
|
||||||
|
}
|
17
src/dev/kske/chess/piece/Rook.java
Normal file
17
src/dev/kske/chess/piece/Rook.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package dev.kske.chess.piece;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>Chess</strong><br>
|
||||||
|
* File: <strong>Rook.java</strong><br>
|
||||||
|
* Created: <strong>01.07.2019</strong><br>
|
||||||
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
||||||
|
*/
|
||||||
|
public class Rook extends Piece {
|
||||||
|
|
||||||
|
public Rook(Color color) {
|
||||||
|
super(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getType() { return Type.ROOK; }
|
||||||
|
}
|
Reference in New Issue
Block a user