Question: Bag class had two member variables one was called size (int type) and the other was item (type T). You must modify that class to
Bag class had two member variables one was called size (int type) and the other was item (type T). You must modify that class to have four member variables called size, item1, item2 and item3. The add method needs to be modified as well. If size is zero, item1 should refer to the item and size needs to be incremented. On the other hand if size is one, item2 should refer to the item and size needs to be incremented. Finally if size is 3, a message should be displayed by the add method saying the bag is full.
You must also write a toString method and test all the methods of the class. The interface must be written as well and main should implement that interface.


Bag Interface java x 2 public interface Bag Interface f 3 public void display() 4 public void ad (T it)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
