Create a class called Cat
that implements the Comparable
interface.
Cat
should provide a public constructor that takes a single double
argument that sets that cat's age.
You should assert that the provided age is not negative.
You should order cats based on their age.
Specifically, compareTo
should return:
Cat
As a reminder, the Comparable
interface comprises a single method: int compareTo(Object other)
.
Stuck? You may find these lessons helpful: