Page 493 - AP Computer Science A, 7th edition
P. 493

  In this lab, students manipulate digital pictures using two- dimensional arrays. Code for the GUI is provided in the lab.
The main concept emphasized is traversal of two-dimensional arrays. Other concepts used are UML diagrams, binary numbers, inheritance, interfaces, abstract methods, constants, and program analysis.
Student activities include:
• Learning how colors are stored in a program. • Modifying a picture.
• Creating a mirror image of a picture.
• Mirroring part of a picture.
• Creating a collage.
• Detecting the edge of a picture.
Special Emphasis
PROCESSING A 2-D ARRAY
A matrix is stored as an array of rows, each of which is also an array. In the lab, a for-each loop is often used for traversal. Here is an example that traverses an array of int:
for (int[] row : matrix)
for (int num : row)
doSomething();
//for each row array in the matrix
//for each int element in the current row
Here is what doSomething can do:
• Access each element in the matrix (count, add, compare,

















































































   491   492   493   494   495