PART A: Note: The following code is written only in main -- you assume there is an array bag and you are not adding any methods to that bag. Write the main program to create two array bags of type string. Place 5 strings of your choice in the first bag and 5 strings (of your choice) in the second bag. Your program must: 1) determine if there are any strings in the first bag that appears in the second bag as well. If there are, print there are repeated strings. Else print the bags have unique values. 2) Print the content of the both bags and if there are repeated values, print that value only once.
PART A:
Note: The following code is written only in main -- you assume there is an array bag and you are not adding any methods to that bag.
Write the main program to create two array bags of type string. Place 5 strings of your choice in the first bag and 5 strings (of your choice) in the second bag. Your program must:
1) determine if there are any strings in the first bag that appears in the second bag as well. If there are, print there are repeated strings. Else print the bags have unique values.
2) Print the content of the both bags and if there are repeated values, print that value only once.
PART B:
Create two linkedBag objects of type string in main. Place 5 strings in the first bag and five strings in the second bag. Then your code must test if the two linkedBag objects are equal or not. You must traverse both linkedBags and test each items to see if they are the same.
Then you must display a message saying the two linkedBags are the same or different.
PART C:
Write a method in the linkedBag class that gets an item of type T and finds out how many of the items in the linkedBag are bigger than that item. Return that count.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images