Question: Fill in the constructor that has no arguments. It must instantiate the array values as an array of size zero. (You must actually create the
Fill in the constructor that has no arguments. It must instantiate the array "values" as an array of size zero. (You must actually create the array, but specify 0 as the size.) Fill in the constructor that takes an int array as an argument. You sh a. 1. ould: 2. Assign to "values" a new array that is the same size as the parameter. b. Copy the elements from the parameter into this new array. Run the JUnit tests (PublicTests) to be sure your constructors are working (you should be passing the test called testConstructors)- if you aren't passing this test, then you won't be able to pass any of the subsequent tests. Fill in the "getSize" method. It simply returns the size of the list. Fill in the "getAt" method. It returns the element whose position in the list matches the parameter. (We are using 0-based indexing.) If the parameter is negative or exceeds the last index of the list then throw an IndexOutOfBoundsException. 3. 4. 5. 6. Fill in the "getTotal" method. It will return the sum of all entries in the list. 7. Fill in the "contains" method. It will return true if the parameter is in the list, false otherwise. 8. Fill in the "add" method. It should add the parameter to the end of the list. You will need to follow the steps below: a. Create another array that is one unit larger than the existing one. b. Copy all of the elements from the existing array over to the new one. c. Add the parameter to the end of the new array. d. Re-assign the instance variable "values" so that it refers to the new array
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
