Question: Using this provided interface: public interface MultiSet { void add( AnyType x ); boolean contains( AnyType x ); int count( AnyType x ); boolean removeOne(

Using this provided interface:

public interface MultiSet { void add( AnyType x ); boolean contains( AnyType x ); int count( AnyType x ); boolean removeOne( AnyType x ); boolean removeAll( AnyType x ); AnyType [] toArray(); }

Make a TreeMultiSet class that implements MultiSet, A TreeMultiSet stores items in sorted order. The data representation can be a TreeMap, in which the key is an item that is in the multiset, and the value represents the number of times the item is stored. Implement the TreeMultiSet

1. TreeMultiSet has an attribute of type TreeMap

2. Use methods that TreeMap provides such as get, put, remove.

3. Override toString in the TreeMultiSet class, so you can specify how the TreeMap prints the attributes.

Also create a runner class with main method to test the code using String and Integers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!