Nbspcreate a class bag multiset that uses an expandable


Create a class bag (multiset) that uses an expandable array to store the bag items. The item type must be a Java String type; that is, the bag will store strings of characters. The class should have the methods listed below. Create a main class to test your bag class. This main class should fill a bag with the keywords of the Java language.

  1. Bag(): default constructor
  2. boolean isEmpty(): determines whether the bag is empty
  3. void print(): prints the bag elements
  4. int getLength(): returns the number of items in the bag
  5. void clear(): removes all of the items from the bag
  6. void add(String item): adds an item to the bag
  7. void removeOne(String item): removes item from the bag; only one occurrence of item should be removed.
  8. void removeAll(String item): removes item from the bag; all occurrences of item should be removed.
  9. int count(String item): counts the number of occurrences of item in the bag.

 

 

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Nbspcreate a class bag multiset that uses an expandable
Reference No:- TGS01110277

Expected delivery within 24 Hours