A chess game using Java(J2EE) and JAVA Swing API.
- Programmed based Object Oriented Programming fully
- Methods and classes are very much dynamic
- GUI is created using Java Swing API.
- Any future code cab be embaded easily.
- Core java is used
- Well commented
- Human vs. Human only
- Change of settings at runtime is not enabled.
There are 10 seperate classes to organize the program properly. RunChess class contains the main method, the starting point of the program. This class also contains the conditions of turn of pieces. Other 9 classes are explained below:
-
Square: This public class extends the Jpanel class of Swing API. This class has four attributes described below: 1.1. status: Contain whethere the square is free or not. 1.2. piece: If the square is not free then contain the piece of the square. 1.3. isActive: Contain whether the square was clicked. 1.4. row: The row position of the square. 1.5. col: The column position of the square. Each of the above attribute has their needed getter or setter method.
-
Board: This is the public class that extends JPanel class of Swing API and contains all the squares and pieces of needed in chess game. This class has all necessary method to initialize methods the board as per user's preferences. This board is very much dynamic. It can initialize with according any of user's prefernce. Even the color of the squares of the board can be changed by just calling the setColor(Color black,Color white) if user wants.
-
Piece: Piece class is an abstract class. This class contains three attributes a) color, b) imageIcon and c) pieceType. This class also contains tow abstract methos defined as getColor() and getPieceType(). getColor() methos returns the color (black/white) of the piece on the other hand getPieceType() method return the type(e.g. pawn) of the piece.
-
Pawn: This class extends abstract class Piece. This class has no attribute but two constructors. The defult constructor construct a pawn of white color. On the other hand the other constructor that receive the color of the piece construct the pawn with defined color. This class implement the abstract methods of its parent class Piece.
-
Knight: Same methods and constructors as pawn but this class construct Knight.
-
Rook: Same methods and constructors as pawn but this class construct Rook.
-
Bishop: Same methods and constructors as pawn but this class construct Bishop.
-
Queen: Same methods and constructors as pawn but this class construct knight.
-
King: Same methods and constructors as pawn but this class construct King.