Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN JAVA PLEASE! (Programming problem 1) First, please specify the Bag ADT using an interface called Baggable. In this interface, you may want to include
IN JAVA PLEASE!
(Programming problem 1) First, please specify the Bag ADT using an interface called Baggable. In this interface, you may want to include the following method headings: add, remove, numOfitems, contains, displayBag. Second, please define a ArrayBag class that implement the Baggable interface using an array. (a).add() method takes an object as input parameter (you can use generic type T or specify some other types such as Integer) the add method will return true if successfully add an item in the bag, otherwise return false. (b).remove() method takes method takes an object as input parameter (you can use generic type T or specify some other types such as Integer) the remove method will return true if successfully remove an item in the bag, otherwise return false. (c). numOfItems() method will return the current size of the bag (d). contains() method will return true if a specific object is in the bag, otherwise return false. (e). displayBag() method will print all the items in the bag. Please add necessary documentations. You are also expected to write your own tester class to thoroughly test your codeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started