InClassExercise19

InClassExercise19 - inspector to open up the object, and...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS112: In-class Exercise 19 More with ArrayLists. 1. Copy the InClass19 folder from the usual locations. 2. Open the project using BlueJ. 3. Edit the source file for InClass19 . 4. Note that this already contains a testRun method. Note the global instance variable numberArray . We made this an instance variable so that we could use the inspector to see its contents. 5. Exercise A. Program a reverse(ArrayList<Integer> a) method that will return an ArrayList<Integer> object that is the reverse of the integers in the array. Use a local variable, say tempArray , to hold the new array that is being built as you traverse the incoming array backwards . Do not forget to instantiate tempArray . Modify the testRun() so as to test this new method (uncomment the relevant test code). Invoke the testRun() method for testing. After invoking, use the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: inspector to open up the object, and keep clicking until you see the contents of the instance variable numberArrayReversed . Are its contents indeed in the reverse order of that of numberArray ? 6. Exercise B. Program a for-loop version min2(ArrayList<Integer> a) method that will return an int that is the minimum of the integers in the array. Modify the testRun() so as to test this new method. Invoke the testRun() method for testing. 7. Exercise C. Program a for-loop version average(ArrayList<Integer> a) method that will return a double that is the average of the integers in the array. Be careful with dividing two integers if you do not wish the result to be rounded down. Modify the testRun() so as to test this new method. Invoke the testRun() method for testing....
View Full Document

This lab report was uploaded on 04/08/2008 for the course CSCI 112 taught by Professor Yuen during the Fall '07 term at Lake Forest.

Ask a homework question - tutors are online