The Chess Game using JAVA
By Yash Parsaniya
This is a Chess Game which is designed in JAVA. This game is designed considering all the rules of Chess.
This is a simple chess application. It implements all the basic rules of Chess game. Players can be selected from a list of existing players, or a new player can be created. User statistics are updated as and when required. The application responds to each selection by indicating all the possible moves. It enforces restriction in case the King is under check. It is a timed game and a player loses his right to move once he runs out of time.
Program consists of Five main classes Piece, Main, Cell, Time and Player.
The function of each classes are as follows:
- Class Piece: It is an abstract class from which all the actual pieces will be extended.
- It holds Seven sub classes which defines all pieces in chess and their functions.
- It provides functionality to hold the color, id and Image Path (for GUI) of all pieces.
- It defines basic rules for movement all the chess piece.
- The King Piece checks if the king is under threat.
- It implements the Cloneable interface to facilitate cloning.
- Class Main: It is the main class that holds the game.
- It holds the current state of the game.
- It creates the GUI and controls the function of all the other classes.
- It handles the click events during the game.
- It provides the functionality to move a piece, change the current board state.
- It provides all the special “King-Related” functions like check, checkmate, restricting moves if king is check etc.
- Class Cell: It is the token Class for the chess-board. 64 objects of this class together makes the Chess Board.
- It holds the piece, and all the related data.
- It provides the functionality to highlight or clean all the possible moves.
- It provides the functionality to indicate that the king is under check.
- It provides the functionality of indicating the current selection and changing the current selection.
- Class Time: It maintains the countdown timer related function.
- It provides the functionality to start or reset the countdown timer.
- It provides the functionality to update the timer every second.
- It provides the functionality to change the chance in-case the time runs out.
- Class Player: It maintains all the records of a Player. Objects of this class are made persistent using File.
- Provides the functionality to fetch the player information from the game’s data file.
- Provides the functionality to update the statistics of a player in the game’s data file.
- Provides the functionality to calculate the win percent of a player throughout his career.