Create a class called Dog
that implements the OurComparable
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.
Do not expose the weight variable.
You should order dogs based on their weight from lightest to heaviest.
Specifically, compareTo
should return:
If the passed value is not a Dog
, throw an IllegalArgumentException
.
As a reminder, the OurComparable
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: