Reference no: EM132316531
JAVA Assignment -
For this assignment you will start creating a simple chess program. Your program will consist of 11 java files in 3 packages: In package until1228
You will not need to change anything in until1228 (as long as it was working for the last assignment). In a package named a05
- ChessDriver.java will be the main file for this assignment. Provided this file below, notice how it uses the Menu class you created in the last assignment.
In a package named chess:
- Piece.java an abstract class representing a chess piece. All the chess pieces will inherit from this class.
- Has 2 protected boolean instance variables one for the color of the piece and one that tracks if the piece has been moved yet.
- Has 2 protected integer instance variable representing the coordinates of the piece.
- Has a protected Board instance variable that is a reference to the board the piece is on.
- Has a 4 parameter constructor which takes the board, a boolean for its color, and 2 integers for its coordinates. The constructor should also initialize the boolean hasBeenMoved to false.
- Has a move method that takes 2 integer parameters and moves the piece to that location if such a move is a valid move.
If there is already a piece at the destination location that piece will be removed from the board.
- Has an abstract boolean method isValidMove which takes 2 integer parameters and returns true if the piece can move to that location.
- Has an abstract char method getSymbol that takes no parameters and returns the symbol of the piece (k for King, q for Queen, r for Rook, b for Bishop, n for Knight, p for Pawn).
If the piece is white the symbol should be uppercase, if the piece is black the symbol should be lowercase.
- King.java, Queen.java, Rook.java, Bishop.java, Knight.java, Pawn.java
- Each has a 4 parameter constructor which takes the board, a boolean for its color, and 2 integers for it coordinates. This constructor can just make use of the Piece constructor.
- Each has an implementation of the isValidMove method. For this week these methods will just always return true. (We will worry about fixing this to follow chess rules next week).
- Each has an implementation of the getSymbol method which returns the correct symbol based on the piece type and color.
- Board.java defines a chess board object.
- Has a protected 8 by 8 2d array of Piece objects representing the positions on a chess board
- Has a single zero parameter constructor that creates the 2d array and then creates all the pieces and puts them in their proper starting position in the array.
- Has a display method that prints a representation of the board to the screen, the format for the display can be seen in the sample output.
- Has a move method that moves a piece to a new location (using the move method of the piece). This method takes 4 parameters: coordinates of the piece and coordinates to move the piece to. The method will print error messages if the coordinates are not on the board or if there is no piece at the first coordinates location.
Attached a sample run of the program, note that coordinates on the board are ordered column then row. So 3 7 is column 3 and row 7.
IMPORTANT: You will submit a single .jar file make sure that:
1) The jar file runs. In project properties under run make sure the main class is set to a05.ChessDriver
2) The jar file includes all your source code. In project properties under packaging make sure .java files are not excluded.
Attachment:- Assignment Files.rar