Question: HOMEWORK JAVA HELP ME PLEASE ChessBoard is class that only stores the list of ChessPiece . A ChessPiece has a Position which is the combination

HOMEWORK JAVA HELP ME PLEASE ChessBoard is class that only stores the list of ChessPiece . A ChessPiece has a Position which is the combination of row and column information that represents the position of the piece on the board. ChessPieces have canMove(Position target) method that returns true if that piece can move to the position specified by the target. This method is implemented differently in each ChessPiece subclass (i.e. Pawn, Rook, Queen, King, Knight and Bishop). ChessPiece has also a Color that can be either White or Black. ChessBoard and all ChessPiece subclasses know how to convert themselves to string (toString() ) and they also know how to clone themselves ( clone() ) ChessBoard additionally has the following methods getPiece(Position pos) method that returns the ChessPiece on the given position or null if none exists. equals(ChessBoard other) compare itself another ChessBoard and returns true if all pieces in both boards represents the same chess board state. boolean canAttack(Position source, Position target) returns if the piece on the source can move to the target and there is another piece on the target that is of the opposite color. Returns false if there is no piece on the source or target. boolean defended(Position pos, Color color) returns if at least a piece of the given Color can move to the given position. Write all of the classes and methods written in bold above according to basic chess rules. (You dont have to consider chess rules like castling, first-move of pawns, en passant. ) Write necessary (not all) constructors of all classes. ? Write a Main class that includes main function. In your main function create instances of the above classes and test your functions by calling them.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!