Ask Question

For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The variable type will store "King", "Queen", "Bishop", etc and the int player will store 0 or 1 depending on whose piece it is. We wish to implement Comparable for the ChessPiece class. Assume that, the current ChessPiece is compared to a ChessPiece passed as a parameter. Pieces are ordered as follows: "Pawn" is a lesser piece to a "Knight" and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are lesser pieces to a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King."22) Which of the following method headers would properly define the method neededto make this class Comparable?

A) public boolean comparable (Object cp)

B) public int comparable (Object cp)

C) public int compareTo (Object cp)

D) public int compare To ()

E) public boolean compareTo (Object cp)

+4
Answers (1)
  1. 8 July, 19:37
    0
    public boolean comparable (Object cp) headers would properly define the method neededto make this class Comparable.

    A) public boolean comparable (Object cp)

    Explanation:

    Chesspieces is class is declaring in programming languages such c+ + or python or java. Inside Chesspiece class declare with two variables names, First variable data type is string which holds names chess board character such as "Queen", "king", "Bishop", and other variable stores Boolean values false or true.

    This program is meant for chess games. Moreover the class been compared zero or one on each character of chess games.

    To compare end user pass the parameter and get the Boolean value either false or true.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The variable ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers