Coders Packet

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:

  1. Class Piece: It is an abstract class from which all the actual pieces will be extended.
    1. It holds Seven sub classes which defines all pieces in chess and their functions.
    2. It provides functionality to hold the color, id and Image Path (for GUI) of all pieces.
    3. It defines basic rules for movement all the chess piece.
    4. The King Piece checks if the king is under threat.
    5. It implements the Cloneable interface to facilitate cloning.


  1. Class Main: It is the main class that holds the game.
    1. It holds the current state of the game.
    2. It creates the GUI and controls the function of all the other classes.
    3. It handles the click events during the game.
    4. It provides the functionality to move a piece, change the current board state.
    5. It provides all the special “King-Related” functions like check, checkmate, restricting moves if king is check etc.


  1. Class Cell: It is the token Class for the chess-board. 64 objects of this class together makes the Chess Board.
    1. It holds the piece, and all the related data.
    2. It provides the functionality to highlight or clean all the possible moves.
    3. It provides the functionality to indicate that the king is under check.
    4. It provides the functionality of indicating the current selection and changing the current selection.


  1. Class Time: It maintains the countdown timer related function.
    1. It provides the functionality to start or reset the countdown timer.
    2. It provides the functionality to update the timer every second.
    3. It provides the functionality to change the chance in-case the time runs out.


  1. Class Player: It maintains all the records of a Player. Objects of this class are made persistent using File.
    1. Provides the functionality to fetch the player information from the game’s data file.
    2. Provides the functionality to update the statistics of a player in the game’s data file.
    3. Provides the functionality to calculate the win percent of a player throughout his career.

Download Complete Code


No comments yet

Download Packet

Reviews Report

Submitted by Yash Parsaniya (YashParsaniya)

Download packets of source code on Coders Packet