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

}
NOTE
• In part (a), the seat numbers go from 0 to SEATS_PER_ROW – 1.
• In part (b), you need the test c < SEATS_PER_ROW–1, because when you refer to seats[r][c+1], you must worry about going off the end of the row and causing an ArrayIndexOutOfBounds exception.
• In part (c), every time you increment index, you need to test that it is in range. This is why you need this test twice: index < SEATS_PER_ROW.
• In part (c), every time you reset the count, you need to reset the lowIndex, because this is the value you’re asked to return.
• In parts (b) and (c), the final return statements are executed only if all rows in the show have been examined unsuccessfully.




























































































   1363   1364   1365   1366   1367