Create a class called Dog
that implements the Comparable
interface.
Dog
should provide a public constructor that takes a single double
argument that sets that dog's weight.
You should assert that the provided weight is greater than zero.
You should order dogs based on their weight.
Specifically, compareTo
should return:
Dog
As a reminder, the Comparable
interface comprises a single method: int compareTo(Object other)
.
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: