Question: 5: Write a program to test the methods that you implemented. Call it BagTester.java. BagTester should do the following: a) It should create two empty

 5: Write a program to test the methods that you implemented.

5: Write a program to test the methods that you implemented. Call it BagTester.java. BagTester should do the following: a) It should create two empty bags, bl and b2. b) Prompt the user to enter an integer from 0 to 7 to choose among the following actions: 1 - add an element to bl. 2 - remove an element from bl. 3- add an element to b2. 4 - remove an element from b2. 5-check if bl equals b2, 6- remove all elements of b2 from bl. 7 - print intersection of bland b2. 0- quit and execute the action chosen by the user. c) Use a loop to repeat step b) until user enters 0 to quit. d) If user chooses actions 1 - 4. then prompt the user to enter the element to be added or removed. e) At the beginning of each iteration of the loop you should print the contents of bags bl and b2. f) At the end of each iteration you must print a description or result of action that was taken (see the sample dialog below)

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!