Question: Create a class called Area that implements the Comparable interface. An area is a rectangle constructed to be width x height. Comparison: Two areas are
Create a class called Area that implements the Comparable interface.
An area is a rectangle constructed to be width x height.
Comparison: Two areas are considered "equal" if their perimeters are the same. An area is considered "less than" another area if its perimeter is smaller. An area is considered "greater than" if its perimeter is larger.
Constructor
public Area (int width, int height) throws IllegalArgumentException
width, height are the width and height of the region
throws IllegalArgumentException for non-positive width or height
You must implement the Comparable interface
You must override the equals method to fulfill the definition of equals.
There are no "setters" or "getters"
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
