Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with creating a driver class and helper class that need to contain minimum of 3 methods. Specification/Analysis: The ADT Bag must contain

I need help with creating a driver class and helper class that need to contain minimum of 3 methods.

Specification/Analysis: The ADT Bag must contain the following operations: create an empty bag that can hold up to 100 items add an item to the end of the list of this bag- insert(item) remove the item at the end of this bag - removeLast() remove an item at a random index from this bag - removeRandom() get the index of the first occurrence of an item from this bag - get(a reference to an item) get a reference to an item at position index of this bag(get(index)), check how many items are there in this bag - size() check to see if this bag is empty - isEmpty() empty this bag - makeEmpty()

Debug/Testing: Note: It is required to store all testing data in a file. It is required to use decomposition design technique. To test the ADT bag design, all operations must be tested. In general, an empty ADT Bag is created, and then, fill the bag, display the list and test other operations. It is not efficient to write everything in main. Method main should be small and the only method in a driver program. A helper class should be created to assist the driver. In the Helper class, minimum three static methods should be included. Method start creates an empty bag and is decomposed/calls other methods such as create and display. Method create should add items into the bag. Method display should display the items in the bag. More methods can be added to test other operations. Method main should call start from the driver program to start the entire testing process. Test the entire design by creating a driver program and a helper class of the driver program. Create a helper class. In the helper class, minimum three static methods should be included. public class Helper{ //method 1 public static void start(){ This void method is decomposed. It creates an empty bag. It calls create with a reference to the empty bag. create adds a list of items into the bag. It calls display with a reference to the bag. display displays the list of items in the bag. } 9 //method 2 public static returnTypeOrVoid create(A reference to a bag){ Using data stored in text files to make items. Add the items into the bag. Note: In this case, you may add String objects to an ADT Bag that can store items of Object type. } //method 3 public static returnTypeOrVoid display(A reference to a bag){ Displays the list of items in the bag. } } Create a driver program. In main of the driver program, call method start to start the entire testing process. public class Driver{ public static void main(String[] args){ Helper.start(); } } The sample testing file may contain items like this: Apple Pear Orange Milk Bread

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

QuickBooks

Authors: Tim Power

1st Edition

1801490090, 978-1801490092

Students also viewed these Databases questions

Question

Are you double jointed in any way?

Answered: 1 week ago