Question: Create an Eclipse project Create a package called prelab Create a class called Set, which has: a . An array of integers, and an integer
Create an Eclipse project
Create a package called prelab
Create a class called Set, which has:
a An array of integers, and an integer variable to keep track of the number of items in the
array
b Create a default construct, which initializes the array to a default size of
i Initialize your counter to
c Create an argumented constructor, which takes in the initial size of the array
i Initialize your counter to
d Create an "add" function, which takes in an integer, and adds it to the end of the array.
i If the array is full in other words, array.length counter then resize the
array, which is done by:
Create a new array which is double the length
Copy over the elements from the old array into the new array
Assign your class's array to be equal to the newly created array
ii Elements should be added at the "counter" position; which should be updated
after a value is inserted
e Create a toString method, which prints out the valid values on the array in a comma
separated list. Try to use a StringBuilder here, for practice.
Test your functions.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
