1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ankoles [38]
2 years ago
13

For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The v

ariable 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)
Computers and Technology
1 answer:
Marina86 [1]2 years ago
3 0

public boolean comparable(Object cp) headers would properly define the method neededto make this class Comparable.

A) public boolean comparable(Object cp)

<u>Explanation:</u>

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.

You might be interested in
Write the definition of a function reverse, whose first parameter is an array of integers and whose second parameter is the numb
GrogVix [38]

Answer:

The c++ function for reversing an array is given. The function is declared void since it returns no value.

void reverse( int arr[], int len )

{

   int temp[len];

   for( int k = 0; k < len; k++ )

   {

       temp[k] = arr[k];

   }

   for( int k = 0, j = len-1; k < len, j>= 0; k++, j-- )

   {

           arr[k] = temp[j];

    }

}

Explanation:

The reverse function uses another array to reverse the elements of the original array.

An integer array is declared, temp[len], having the same length as the input array.

int temp[len];

To begin with, the elements of the input array are copied in the temp array.

for(int k = 0; k < len; k++ )

{

       temp[k] = arr[k];

}

Next, the elements of the input array are given new value.

The temp array, in reverse order, is copied into the input array.

for( int k = 0, j = len-1; k < len, j>= 0; k++, j-- )

{

           arr[k] = temp[j];

}

The above for loop makes use of two variables simultaneously.

While the array, arr is proceeding from first element to the next, the array temp begins with the last element and goes down to the previous element.

Now, the input array, arr, contains the elements in reverse order.

The complete program is given.

#include <iostream>

using namespace std;  

 

void reverse( int arr[], int len );

void reverse( int arr[], int len )

{

   int temp[len];

   

   for(int k = 0; k < len; k++ )

   {

       temp[k] = arr[k];

   }

   

   for( int k = 0, j = len-1; k < len, j>= 0; k++, j-- )

   {

           arr[k] = temp[j];

   }

   

}

int main()  

{

   int len = 5;    

   int arri[len];    

   for( int l = 0; l < len; l++ )

   {

       arri[l] = l;

   }

   

   reverse( arri, len );    

   return 0;

}

8 0
2 years ago
Is it okay to leave your car running while parked?
diamong [38]
No because the battery will die and it wont run anymore in other cases you would ask another person for help and connect cables to their car.
8 0
3 years ago
What is an administrator?
Drupady [299]
A person responsible for running a business, organization, etc.
3 0
2 years ago
What is output by the following line of code?
astraxan [27]

Answer:int x = 5;

if(x < 5)

cout << "line 1 ";

cout << "line 2";

A. line 1 line 2 B. line 1 C. line 2

D. line 1 E. line 1line 2

line 2

2. What would be output by the following code? _______

int x = 0;

while(x < 5)

{

cout << x << " ";

x++;

}

A. 0 1 2 3 4 5 B. 1 2 3 4 5 C. 0 1 2 3 4

D. 0 E. 0 0 0 0 0

3. After execution of the following code, what will be the value of input_value if the value 3 is entered at the keyboard at run time? ________

cin >> input_value;

if (input_value > 5)

input_value = input_value + 5;

else if (input_value > 2)

input_value = input_value + 10;

else

input_value = input_value + 15;

a. A. 8

b. B. 13

c. C. 18

d. D. 0

e. E. 5

4. What would the user see displayed on the screen after the following lines of code are executed?¬¬________

int i = 6;

if (i == 10)

cout << “value: “ << i;

else

cout << "hmmm";

A. value: i B. value: 10

C. hmmm D. value: ihmmm

E. value: 10

Hmmm

5. What is the output of the following lines of code? ______

for(int i=0; i<4; i++)

cout << (i * 3) << " ";

A. 0 1 2 3 4 B. 0 3 6 9

C. 0 3 6 9 12 D. 0 1 2 3 E. 0 0 0 0

Explanation:

6 0
2 years ago
To whom the script most important
baherus [9]
The scripter as he made the script.
5 0
3 years ago
Other questions:
  • A network administrator is using packet tracer to mock up a network that includes iot devices. What can the administrator do fro
    15·1 answer
  • Write a program that reads in text from standard input (hint: use Scanner) and prints out the number of words in the text. For t
    5·1 answer
  • Smoking is a REALLY good example of a choice that can have negative effects on the smoker's health, AND the well-being of others
    9·1 answer
  • NEED HELP NOW 25 POINTS!!!!!!
    15·2 answers
  • the technique of blocking some parts of a photograph to emphasize (or draw attention to) another part of the same photograph is
    8·1 answer
  • Suppose you're currently completing an examination online. When you're finished, you click on Reset Exam. Why would you do this?
    8·1 answer
  • To implement a small database, a database designer must know the "1" and the "M" sides of each relationship and whether the rela
    13·1 answer
  • Unconformities develop when new sedimentary layers accumulate atop old, eroded layers, resulting in a geologic hiatus. Which of
    9·1 answer
  • k-means clustering cannot be used to perform hierarchical clustering as it requires k (number of clusters) as an input parameter
    15·1 answer
  • What is data science?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!