Visit www.myprogramminglab.com to complete select exercises online and get instant feedback.
Exercise
Listed next is the skeleton for a class named Inventoryltem. Each inventory item has a name and a unique ID number:
class Inventoryltem{private String name;private int uniqueItemID;}
Flesh out the class with appropriate accessors, constructors, and mutatators. The uniqueItemIDs are assigned by your store and can be set from outside the Inventoryltem class—your code does not have to ensure that they are unique. Next, modify the class so that it implements the Comparable interface. The compareTo() method should compare the uniqueltemID’s; e.g., the Inventoryltem with item ID 5 is less than the InventoryItem with ID 10. Test your class by creating an array of sample InventoryItem’s and sort them using a sorting method that takes as input an array of type Comparable.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.