Question: In the lecture we wrote a BagInterface and a Bag class that were generic. Bag class had two member variables one was called size (int

 In the lecture we wrote a BagInterface and a Bag class
that were generic. Bag class had two member variables one was called

In the lecture we wrote a BagInterface and a Bag class that were generic. 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, item l, item2 and item3. The add method needs to be modified as well. If size is zero, item 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

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!