Examlex

Solved

Code Description Ch 07-1

question 33

Essay

Code Description Ch 07-1
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"
a "Bishop" and "Knight" are equivalent for this example
both "Bishop" and "Knight" are lesser pieces to a "Rook"
a "Rook" is a lesser piece to a "Queen"
a "Queen" is a lesser piece to a "King".

-Refer to Code Description Ch 07-1: To implement Comparable for the ChessPiece class, the current ChessPiece's type is compared to a ChessPiece passed as a parameter. The method should return 0 if the types are equal, -1 if this piece's type is a lesser piece than the parameter's type, and 1 if this piece's type is a greater piece than the parameter's type. Create this code.


Definitions:

Schedule C

A tax form used by sole proprietors in the United States to report the income and expenses of their business, used to calculate net business profit or loss.

Primarily Rental

Describes a property used mainly for rental purposes, affecting its tax treatment and eligible deductions.

Primarily Personal

A classification often used in taxation to describe expenses or activities that are mainly for personal benefit and not business or trade related, affecting their deductibility.

Self-Employment Income

Self-Employment Income is money earned from carrying out business activities or providing services as an independent contractor, rather than as an employee.

Related Questions