Question: 3.2 Implement the class Dictionary Dictionary keeps track of String-Integer associations (key-value). . The Dictionary class implements the interface Map . It uses an array

 3.2 Implement the class Dictionary Dictionary keeps track of String-Integer associations(key-value). . The Dictionary class implements the interface Map . It usesan array (first instance variable) to store each association. The elements in

3.2 Implement the class Dictionary Dictionary keeps track of String-Integer associations (key-value). . The Dictionary class implements the interface Map . It uses an array (first instance variable) to store each association. The elements in this array are of type Pair, a class that will be public. A Pair type object must store an association, "key" and "value" of type String and Integer respectively. Study the pre-solved file provided. Note this is an alternative solution until nested classes are taught in class. You must treat your array of items as a stack. So the bottom of your stack will be element 0, while the top of the stack will be the non-null element at the highest position. Use a counter (second instance variable) that will tell you how many items are in your table. . .Finally, because the Dictionary class stores an arbitrarily large number of associations, you will need to use the dynamic table technique (as shown in part 1). The initial size of the array will be 10, while its increment will be 5 whenever the array is full. These two values will be treated as constants. .You clearly need to implement all methods of the interface. Do not forget to consider that the rightmost association (element of type Pair) will always be the top most of the stack! You will therefore have to go through your table in the opposite direction. .Add a toString() method that prints your table elements from last to first (top of stack to bottom of stack) . It has getters, getCount) which returns the current number of items in the dictionary, and getCapacityo which returns the current length of the array . DictionaryTest.java includes a series of tests for your implementation. Note that you do not have to handle exceptional inputs in your solution (for example, removing, getting, or replacing a key that doesn't exist.) public class Dictionary implements Map= 9 ; i--) { res elems[i]; if).. return res

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!