Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class RandomInteger. This class should have an private ArrayList to store data. a. Create a constructor for the class to create an empty

Create a class RandomInteger. This class should have an private ArrayList to store data.

a. Create a constructor for the class to create an empty array list.

b. Create a public method (addToFront) that takes one parameter, an int. The int will be inserted as the first element of the ArrayList, moving all the other elements up by one position. Hint: Before you start writing code, read the descriptions of the relevant methods in the API for ArrayList.

c. Create a public method (addToBack) that takes one parameter, an int. The int will be inserted as the last element of the ArrayList.

d. Create a public method (addSorted) that takes one parameter, an int. Assuming the ArrayList is sorted, the int should be inserted in the correct location that would keep the array sorted (you do not need to check if the array is sorted. Just assume it is).

e. Create a public method (productSorted) that takes one parameter, an int. Assuming the ArrayList is sorted, the int should be multiplied by the first int in the ArrayList, with the product replacing the first int and then being moved to the correct location that would keep the array sorted (you do not need to check if the array is sorted. Just assume it is).

f. Create a public method (selectionSort) that sorts the ArrayList using the selection sort algorithm (see here). g. Return an int array whose entries are equal to the ArrayList. This array should be used to perform your JUnit test using the assertArrayEquals method.

g. Return an int array whose entries are equal to the ArrayList. This array should be used to perform your JUnit test using the assertArrayEquals method.

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago

Question

b. Does senior management trust the team?

Answered: 1 week ago