Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lecture Notes on Two Dimensional Arrays | CSIS 110, Study notes of Javascript programming

Material Type: Notes; Professor: Hanks; Class: Intro to Programming in Java; Subject: Computer Science Info Systems; University: Fort Lewis College; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-8vo-1
koofers-user-8vo-1 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSIS 110 – Lecture 30
Reminders
Program due today
Homework due Monday
Quiz Wednesday.
Focus on nested for loops and 2D arrays. I strongly recommend going over the various
examples in the forloop and twodim projects. Play around with the methods. Make sure
you understand how they work. Tweak them slightly to make them work a little bit
differently.
Also javadoc, user-input validation, public/private.
Last Time: Two-dimensional arrays
Let's look at the TwoDim2 class (in two-dim project): What does the constructor do?
What about the initializeArray method?
Let's write a method getMax that returns the maximum value in the array.
Let's write a method getRow to return the i'th row of the array.
pf3

Partial preview of the text

Download Lecture Notes on Two Dimensional Arrays | CSIS 110 and more Study notes Javascript programming in PDF only on Docsity!

CSIS 110 – Lecture 30

Reminders Program due today Homework due Monday Quiz Wednesday. Focus on nested for loops and 2D arrays. I strongly recommend going over the various examples in the forloop and twodim projects. Play around with the methods. Make sure you understand how they work. Tweak them slightly to make them work a little bit differently. Also javadoc, user-input validation, public/private. Last Time: Two-dimensional arrays Let's look at the TwoDim2 class (in two-dim project): What does the constructor do? What about the initializeArray method? Let's write a method getMax that returns the maximum value in the array. Let's write a method getRow to return the i'th row of the array.

Lab 21 Write a method getMaxByRow in class TwoDim2. This method returns a one- dimensional array – the number of elements in the one-dimensional array is the same as the number of rows in the 2D array anArray. The method should set the value of each element of the one-dimensional array to the maximum value in the corresponding row of the 2D array. For example, if the 2D array is: 10 7 19 2 -3 5 0 8 12 4 8 - Then this method should return a one-dimensional array containing 3 elements: 19 8 12 Suggested approach: Write a private method getMax( int[] row ) that returns the maximum value in a one-dimensional array. Use a for loop to call this method for each row in the 2D array, filling in the one-dimensional array one element at a time. Email the file TwoDim2.java to me – use the subject "Lab 21"