Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Lab Steps Exercise 1: Review of Array-Based Lists Create a project using the classes in this zip file (Links to an external site.)Links to

Java

Lab Steps

Exercise 1: Review of Array-Based Lists

Create a project using the classes in this zip file (Links to an external site.)Links to an external site. and name it "A Simple ArrayList Class." Compile it, run it, and review the code that is given carefully. This code tests the ArrayList class discussed in the lecture.

Exercise 2: Implementing an Array List

Modify the class ArrayList given in Exercise 1 by using expandable arrays. That is, if the list is full when an item is being added to this list, the elements will be moved to a larger array. The new array should have twice the size of the original array.

Exercise 3: Using an Array-Based List

Using the class ArrayList completed in the previous exercise, write a program to store 1,000 random numbers, each in the interval [0, 500]. The initial size of the array in the class should be set to 100. Print the numbers.

Exercise 4: Implementing a Bag Class

Create a class bag (multiset) that uses an expandable array to store the bag items. The item type must be a Java String type; that is, the bag will store strings of characters. The class should have the methods listed below. Create a main class to test your bag class and demonstrate each of these methods. This main class should fill a bag with the keywords of the Java language.

Bag(): default constructor

boolean isEmpty(): determines whether the bag is empty (still need it)

void print(): prints the bag elements (still need it)

int getLength(): returns the number of items in the bag (still need it for expansion)

void add(String item): adds an item to the bag

void removeOne(String item): removes item from the bag; only one occurrence of item should be removed.

.

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

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions