(Object -oriented programing) 1. Here is Java code to create a chess piece: public class ChessPiece { public String pieceName; public String position; public ChessPiece(String pieceName, String position){ this.pieceName = pieceName; this.position = position; } } Complete the code by adding one child class for each type of piece. Every type of piece has an attribute containing a description of its allowed movements on the chess board. Also, every type of piece must contain a method that can print the description of its movements. For instance, a message printed to the screen for the rook could be: "Can go in a straight line until it encounters the edge of the board or another piece."
(Object -oriented programing)
1. Here is Java code to create a chess piece:
public class ChessPiece {
public String pieceName;
public String position;
public ChessPiece(String pieceName, String position){
this.pieceName = pieceName;
this.position = position;
}
}
Complete the code by adding one child class for each type of piece. Every type of piece has an attribute
containing a description of its allowed movements on the chess board.
Also, every type of piece must contain a method that can print the description of its movements. For
instance, a message printed to the screen for the rook could be:
"Can go in a straight line until it encounters the edge of the board
or another piece."
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 12 images