Question: Please implement class LinkedBag focusing on method removeAllOccurrences. This method removes all occurrences of the given entries from a bag. Our programs output must be

Please implement class LinkedBag focusing on method removeAllOccurrences. This method removes all occurrences of the given entries from a bag. Our programs output must be identical to the following same output:

Output must be exactly identical to the picture below, Also please explain everything that is being done explicitly. Thank you for your help.

Please implement class LinkedBag focusing on method removeAllOccurrences. This method removes all

------------------------------------------------------------------------------------------ LinkedBag.java (CODE) ----------------------------------------------------------------------

public final class LinkedBag implements PrimaryDataStructureBagInterface { private Node firstNode; private int numberOfEntries; public LinkedBag() { firstNode = null; numberOfEntries = 0; } @Override public boolean removeAllOccurrences(T[][] entries) { } private class Node { private T data; private Node next; private Node(T dataPortion) { this(dataPortion, null); } // end constructor private Node(T dataPortion, Node nextNode) { data = dataPortion; next = nextNode; } } }

----------------------------------------------------------------------------------------- LinkedBagCSC220JavaDriver.java ( Do NOT CHANGE CODE) ----------------------------------------------------------------------

public class LinkedBagCSC220JavaDriver { public static void main(String[] args) { System.out.println("=== LINKED BAG 220 JAVA =========================================================="); System.out.println("[+] Creating a CSC220 LinkedBag..."); PrimaryDataStructureBagInterface csc220Bag = new LinkedBag(); testAdd(csc220Bag); testRemoveAllOccurrences(csc220Bag); System.out.println("=== LINKED BAG 220 JAVA =========================================================="); } private static void displayBag(PrimaryDataStructureBagInterface aBag) { System.out.print("[>] The bag now contains " + aBag.getCurrentSize() + " string(s): \t"); Object[] bagArray = aBag.toArray(); for (Object bagArray1 : bagArray) { System.out.print(bagArray1 + " "); } System.out.println(); } private static void testRemoveAllOccurrences(PrimaryDataStructureBagInterface aBag) { // Removing all occurrences of the given entries from a bag System.out.println("[+] Creating... a 2D test array with the below contents: \t"); String[][] testArray = { {"A", "A", "A", "A", "A", "A"}, {"B", "A", "Bb", "B", "Bb", "B"}, {"C", "B", "_", "A"}, {"n", "u", "l", "l"} }; for (String[] row : testArray) { System.out.print("\t\t\t\t\t"); for (String col : row) { System.out.print(col + " "); } System.out.println(""); } aBag.removeAllOccurrences(testArray); displayBag(aBag); } private static void testAdd(PrimaryDataStructureBagInterface aBag) { // Adding strings String[] contentsOfBag = { "A", "_", "_", "G", "Bb", "A", "_", "u", "n", "o", "A", "o", "d", "Bb", "A", "A", "l", "l" }; System.out.print("[+] Adding.... these items to the bag: \t"); for (String entry : contentsOfBag) { aBag.add(entry); System.out.print(entry + " "); } System.out.println(); displayBag(aBag); } }

----------------------------------------------------------------------------------------- PrimaryDataStructureBagInterface.java ( Do NOT CHANGE CODE) ----------------------------------------------------------------------

public interface PrimaryDataStructureBagInterface { public int getCurrentSize(); public boolean isEmpty(); public boolean add(T newEntry); public boolean removeAllOccurrences(T[][] entries); public T[] toArray(); }

PART A - The Linked Bag, 20 points Please implement class LinkedBag focusing on method removeA110ccurrences. This method removes all occurrences of the given entries from a bag. Our program's output must be identical to the following same output: === LINKED BAG 220 JAVA ===== [+] Creating a CSC220 LinkedBag... [+] Adding.... these items to the bag: A--G Bb A _ Uno A od Bb A A 11 [>] The bag now contains 18 string(s): 11 A A Bb do onu _ A Bb G__A [+] Creating... a 2D test array with the below contents: A A A A A A _ nuli [+] Removing 2D test array items from the bag... [-] Converting 2D array to 1D... (-) Removing duplicates in 10 array... [>] The final in array now contains: A B Bb C nul (-) Removing the final 10 array items from the bag... [>] The bag now contains 4 string(s) : Good --- LINKED BAG 220 JAVA =REREN

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!