-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResizableArrayBagTest.java
More file actions
35 lines (27 loc) · 1.23 KB
/
ResizableArrayBagTest.java
File metadata and controls
35 lines (27 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Arrays;
public class ResizableArrayBagTest{
public static void main(String[] args){
BagInterface<String> bag_1 = new ResizableArrayBag<>();
BagInterface<String> bag_2 = new ResizableArrayBag<>();
bag_1.add("A");
bag_1.add("Q");
bag_1.add("Q");
bag_1.add("R");
bag_1.add("X");
bag_1.add("Z");
bag_2.add("A");
bag_2.add("A");
bag_2.add("U");
bag_2.add("X");
bag_2.add("Y");
bag_2.add("Y");
bag_2.add("Y");
bag_2.add("Y");
bag_2.add("Z");
System.out.println("Bag1 uses a resizable array bag and contains the following: [A, Q, Q, R, X, Z]");
System.out.println("Bag2 uses a resizable array bag and contains the following: [A, A, U, X, Y, Y, Y, Y, Z]");
System.out.println("Applying the union method with Bag2 as the parameter: " + Arrays.toString(bag_1.union(bag_2).toArray()));
System.out.println("Applying the intersection method with Bag2 as the parameter: " + Arrays.toString(bag_1.intersection(bag_2).toArray()));
System.out.println("Applying the difference method with Bag2 as the parameter: " + Arrays.toString(bag_1.difference(bag_2).toArray()));
}
}