Question: Consider the LinkedBag class which implements the interface BagInterface (the source code for both has been provided to you on Moodle). Add the following
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 is Duplicated (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.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
