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

If anyone can help im lost an explanation would be great. 2. The following exerc

ID: 3619996 • Letter: I

Question

If anyone can help im lost an explanation would be great.

2. The following exercise is intended to encourage you to think of testing in a
more rigorous way than you may be used to. The exercise also hints at the
strong relationship between specification clarity, faults, and test cases.1
(a) Write a Java method with the signature
public static Vector union (Vector a, Vector b)
The method should return a Vector of objects that are in either of the
two argument Vectors.

(b) Upon reflection, you may discover a variety of defects and ambiguities
in the given assignment. In other words, ample opportunities for faults
exist. Identify as many possible faults as you can. (Note: Vector is a Java
Collection class. If you are using another language, interpret Vector as a
list.)

(c) Create a set of test cases that you think would have a reasonable chance
of revealing the faults you identified above. Document a rationale for
each test in your test set. If possible, characterize all of your rationales in
some concise summary. Run your tests against your implementation.

(d) Rewrite the method signature to be precise enough to clarify the defects
and ambiguities identified earlier. You might wish to illustrate your specification
with examples drawn from your test cases.

Explanation / Answer

dear... a. The set represented by v1 to be a representation of the set and the set union of the elements from the sets represented by v1 and v2 . i.e., that contains all the elements that appear in either the set represented by v1 or the set represented by v2. java code: import java.util.Set; public class Main { public static Set union(Set setA, Set setB) { Set tmp = new TreeSet(setA); tmp.addAll(setB); return tmp; } public static boolean isSubset(Set setA, Set setB) { return setB.containsAll(setA); } public static boolean isSuperset(Set setA, Set setB) { return setA.containsAll(setB); } public static void main(String args[]) { TreeSet set1 = new TreeSet(); TreeSet set2 = new TreeSet(); set1.add('A'); set1.add('B'); System.out.println("set1: " + set1); System.out.println("set2: " + set2); System.out.println("Union: " + union(set1, set2)); } }