Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please follow all instructions carefully and use JAVA to do the following: Pleas

ID: 3738362 • Letter: P

Question

Please follow all instructions carefully and use JAVA to do the following:

Please refer to the following:

https://repl.it/@tom_don/SpicyRigidArrays --> ArraySetTests.java

https://repl.it/@tom_don/PreemptiveIckyRoutine -->impl1/ArraySet.java

https://repl.it/@tom_don/ToughDamagedAddress -->impl2/ArraySet.java

2 GENERIC Array SeT The code distributed with this lab contains two directories labeled impl1 and imp12 which contain slightly different implementations of an ArraySet. Set classes are meant to track a collection of unique objects: no redundancy is allowed so that items are either in the set or not in the set. The set supports . Two constructors add(x): ensure that item x is in the set remove(x): ensure that item x is NOT in the set contains (x): true if item x is in the set, false otherwise · toString() : produce a string version of the set These methods are supported by an underlying array which is expanded on demand in a similar fashion to the strategy used by ArrayList. IMPORTANT: You are not writing the Arrayset class in this lab. You are testing two implementations to figure out which is correct and which is faulty. To test, however, you must understand what the class is supposed to do which is facilitated by the documentation below 2.1 Directorv Structure of Lab Use the directory structure provided in the code distribution which should have the following files lab8pack : rename to your NetID_LabNum_L8 answers to this file + ANALYSIS.txt +-. ArraySetTests.java : Add tests to this file + impl1/ : Add +ArraySet.javaDo not modify, provided imp12/ +ArraySet.javaDo not modify, provided +- junit-4.12.jar

Explanation / Answer

Hi,

Below is the ArraySetTests.java class with all the required JUnit Tests:

Consider the line import impl1.ArraySet;

while testing impl2 implementation of ArraySet, you have to change impl2 from impl1 in above statement.

After running all the tests, we can confirm that impl2 implementation is the correct implementation of ArraySet, as impl1 is failing the test testRemove2(). Because remove() method of impl1 replaces the item to be removed with null, which causes NullPointerException while calling toString(). Whereas impl2's remove() method shifts all the items after the item to be deleted so that the item to be deleted is replaced with the next item in the array and thereby ignores null. This is why impl2 passes all the JUnits and hence is the correct implementation.

Let me know if you have any questions.