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