Create a class called Fish
that implements the Comparable
interface.
Fish
should provide a public constructor that takes a single double
argument that sets that fish's length.
You should assert that the provided length is greater than zero.
You should order fish based on their length, but in reverse order.
(Small fish rule!)
Specifically, compareTo
should return:
Fish
As a reminder, the Comparable
interface comprises a single method: int compareTo(Object other)
.
Stuck? You may find these lessons helpful: