The vegetable class contains 4 vegetables: Lettuce, potatoes, carrots and onions and 2 variables their weight and
Fantastic news! We've Found the answer you've been seeking!
Question:
The vegetable class contains 4 vegetables: Lettuce, potatoes, carrots and onions and 2 variables their weight and ripeness level.
Create comparable interface to determine the order of the vegetable variables. The comparing() method will compare 2 vegetable objects. It shall return whether which object is less than, equal to one another or greater than one another.
1. Lettuce is greater than all the other vegetables
2. Potatoes and Carrots are greater than onions
3. When comparing potatoes and carrots, the vegetable with the higher weight is greater.
4. To break tiebreakers, if the vegetables weight are within 0.05kg of one another, their ripeness value will be the deciding factor.
Posted Date: