Flesh out the class with appropriate accessors constructors


Question: Listed next is the skeleton for a class named Inventory Item. Each inventory item has a name and a unique ID number:

class InventryItem

{

  private String name;

  Private int uniqueItemID;

}

Flesh out the class with appropriate accessors, constructors, and mutatators. The unique Item ID's are assigned by your store and can be set from outside the Inventory Item class-your code does not have to ensure that they are unique. Next, modify the class so that it implements the Comparable interface. The compare To () method should compare the unique Item ID 's; e.g., the Inventory Item with item ID 5 is less than the Inventory Item with ID 10. Test your class by creating an array of sample Inventory Item ‘s and sort them using a sorting method that takes as input an array of type Comparable.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Flesh out the class with appropriate accessors constructors
Reference No:- TGS02404861

Now Priced at $10 (50% Discount)

Recommended (99%)

Rated (4.3/5)