Question: Write the class Bag that implements the Baginterface using an Array. Baginterface should have the following methods (note that this code is given to you


Write the class Bag that implements the Baginterface using an Array. Baginterface should have the following methods (note that this code is given to you on Canvas already). Write the main method to create two bags. One bag is of type Car and the other bag is of type string. Place 3 car objects and 4 strings in each bag. Test each of the following methods in the class. Bag +getCurrentSize(): integer +isEmpty ): boolean +add (newEntry: T): boolean +remove): T +remove (anEntry: T): boolean +clear: void +getFrequencyOf (anEntry: D): integer +contains (anEntry: T): boolean +toArrayO: T[I 2- Answer the following
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
