{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern