{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Picture Lab.docx - A4 Exercises(Picture Lab public class...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
A4 Exercises (Picture Lab) public class IntArrayWorker { private int[][] matrix = null; public void setMatrix(int[][] theMatrix) { matrix = theMatrix; } public int getTotal() { int total = 0; for (int row = 0; row < matrix.length; row++) { for (int col = 0; col < matrix[0].length; col++) { total = total + matrix[row][col]; } } return total; } public int getTotalNested() { int total = 0; for (int[] rowArray : matrix) { for (int item : rowArray) { total = total + item; } } return total; } public void fillCount() { int numCols = matrix[0].length; int count = 1; for (int row = 0; row < matrix.length; row++) { for (int col = 0; col < numCols; col++) { matrix[row][col] = count; count++; } } } public int getCount(int number) { int counter = 0; for (int r = 0; r < matrix.length; r++) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
for (int c = 0; c < matrix[0].length; c++) { if (number == matrix[r][c]) { counter++; } } } return counter } public int getLargest()
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}