Question: solve by using the code that i put Consider the LinkedBag class which implements the interface BagInterface (the source code for both has been provided





Consider the LinkedBag class which implements the interface BagInterface (the source code for both has been provided to you on Moodle). Add the following methods to BagInterface and implement them in class LinkedBag: 1) void replace (T oldEntry, T newEntry) replaces any entry that is equal to oldEntry with the new entry newEntry. For example, suppose that replace (A, D) is called on this bag {A, B, C, A). The resulting bag should be {D, B, C, D). 2) boolean is Duplicated (T anEntry) returns true if the entry anEntry appears more than one time in the bag and false otherwise. For example, calling is Duplicated (B) on the resulting bag in part 1 should return false, but isDuplicated (D) should return true. 3) void doubleBag () adds to the bag a copy of each entry that appears in the bag. For example, calling doubleBag () on the resulting bag in part 1 should change the bag contents to {4'D, 2'B, 2'C). Create a test class called LinkedBagTest. In its main method, create and initialize the contents of a bag and use the methods you implemented above to test your implementation. Your implementation must be as efficient as possible. Data structure and Algorithms, Spring 2021-22 3/3 package Bag: /** A class of bags whose entries are stored in a chain of linked nodes. The bag is never full. @author Frank M. Carrano @author Timothy M. Henry @version 4.1 *7 public final class LinkedBag
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
