Question: I need help with an implementation of a Hashtable in Java using a Linked list to resolve has collisions. Please follow the rules/specifications in the
I need help with an implementation of a Hashtable in Java using a Linked list to resolve has collisions. Please follow the rules/specifications in the below screenshots and use the interface. I know there are multiple ways to solve it, but the specifications are required and if they are not implemented then the code will get a 0 (even if it technically works) So please I am begging you follow the specifications and interface below! Also, if you can write at least one test method would be fantastic but it isn't a must. Just please follow the specifications and requirements. Thank you! I wish you a great day! : D



HashtableMap Specifications You must define a public class HashtableMap that implements this provided MapADT interface e. Your implementation must: be left in the default package: ie. do not define it within a named package. be defined with two generic type parameters in this order: which allow it to be used with different types of key-value pairings. include two constructors with the following signatures: O public HashtableMap(int capacity) o public HashtableMap() // with default capacity = 20 Remember that you cannot instantiate an array with associated generic types in Java. So you should instantiate without the generic types, and then cast to the complete type with generics. This will produce an unchecked cast warning that can either be ignored, or suppressed by adding the @SuppressWarnings("unchecked") annotation in front of your method's definition. use exactly one private array instance field (update 10/1: this single array instance field should be one dimensional, and additional private primitive fields are allowed) . grow by doubling its capacity and rehashing, whenever its load factor becomes greater than or equal to 80%. Define private helper methods to better organize the code that does this. store new values in your hash table at the index corresponding to the absolute value of the key's hashCode() } modulus the HashtableMap's current capacity. When the put method is passed a key that is null or is equal to a key that is already in your hash table, that call should return false without making any changes to the hash table. The put method should only return true after successfully storing a new key-value pair. include a remove method that returns a reference to the value associated with the key that is being removed. When the key being removed cannot be found in the HashtableMap, this method should instead return null. include a size method that returns the number of key-value pairs stored in this collection, and include a clear method that removes all key-value pairs from this collection without changing the underlying array capacity. use chaining to handle hash collisions, and make use of the java.util.LinkedList class for this purpose. It will also be helpful to create a helper class that allows you to group together a key-value pair within a single object. Then you can store these key-value pair objects within the appropriate java.util.LinkedList. throw exceptions as indicated within the comments of the MapADT interface. You should make use of java.util.NoSuchElementException for this. NOT make use of any classes from libraries like java.util other than the two exceptions listed above: you may use java.util.LinkedList, and java.util. No SuchElementException. HashtableMapTests Requirements In addition to your HashtableMap.java implementation, you must develop and submit some tests in a source file named HashtableMapTests.java. These tests must include at least five distinct methods with the following names and signatures. Each of these methods should return true when the HashtableMap class that they run with behaves correctly, and false when any unexpected (or buggy) behavior is detected. Each test should be designed to test a different feature of the HashtableMap implementation. Note that these methods should not throw exceptions, since any expected exceptions should be caught to verify correct expected behavior, and any unexpected exceptions should be caught and reported as faulty behavior (returning false). Be sure to provide descriptive comments for each of these test methods, which describe the high-level functionality that they are designed to check for. Note that these test methods should NOT be JUnit5 tests for this assignment. public static boolean test1() { /* test code here */ } public static boolean test2() { /* test code here */ } public static boolean test3() { /* test code here */ } public static boolean test4() { /* test code here */ } public static boolean test5() { /* test code here */ } import java.util.NoSuchElementException; public interface MapADT { public boolean put(KeyType key, Value Type value); public Value Type get(KeyType key) throws NoSuchElementException; public int size(); public boolean containsKey(KeyType key); public Value Type remove (KeyType key); public void clear(); }