Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this assignment is to develop your ability to code GENERIC classes and methods and to understand how the ArrayList data structure dynamically

image text in transcribed
image text in transcribed
image text in transcribed
The purpose of this assignment is to develop your ability to code GENERIC classes and methods and to understand how the ArrayList data structure dynamically adjusts its capacity to store objects. We will do this by taking a do-it- yourself (DIY) approach by building our own ArrayList-Like data structure called "ArrayBox". This assignment has its own set of slides that we discussed in class. Those slides are available in Moodle under "Slides" and are entitled simply "arraybox.pdf". Refer to that presentation for details of what needs to be replicated. In general, you must: Create a generic class called ArrayBox that uses a STATIC array of SIZE 2 elements only. Also have the class contain an index variable that refers to the index of the next available spot in your array that can contain an object. Your ArrayBox declaration needs to look similar to this: public class ArrayBox private E[)elements = (ED) (new Object[2]); private int end_idx = 0; within this class implement the following public methods declared EXACTLY AS: public int size) public boolean add Ee) public Eget(int index) public E set(int index, E element) public E remove(int index) You may add additional private methods as you wish to modularize the code better but the above methods must be in your class. in addition you must create code that will resize the static array as needed as described in class. Namely, if a call to the add() method realizes the static array is FULL then your code must recreate a new array doubled in size before completing the add() request. Again refer to the slides "arraybox.pdf". Create a Driver class called ArrayBoxDriver (this will contain your main method). Have this class create an instance of ArrayBox of data type and call a mainMenu() method: public class ArrayBoxDriver { private ArrayBox box = new ArrayBox(); public static void main(String[] args) mainMenu(); then have this class produce a "menu" that looks similar to this: =[==[==[= (================================)=)= )= =[==[==[=[ Welcome to ArrayBox =)==]=>] = ) EEEEEEEEEEEEEEEEEEEE =====] =]==] ==) = Choose... 1. Add an element(String) to our box. 2. Remove an element(String) from our box. Choose... 1. Add an element(String) to our box. 2. Remove an element(String) from our box. 3. Replace(set) an element(String) from our box. 4. List the contents of the box. 5. Exit program Now complete the program by coding the menu options 1-5 above. In order to help you understand exactly what your program should do (inputs and outputs), I have included a runtime version of this assignment. CLICK HERE TO DOWNLOAD MY VERSION Unzip and run my program by running the "runme.bat" file. Replicate your program to behave like mine. Once you are satisfied with your assignment please ZIP(archive it) and upload below. The ONLY deliverable is your uploaded code

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

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

What position do you seek?

Answered: 1 week ago

Question

1. What is meant by Latitudes? 2. What is cartography ?

Answered: 1 week ago

Question

What is order of reaction? Explain with example?

Answered: 1 week ago