Page 617 - AP Computer Science A, 7th edition
P. 617
∗ @return true if two adjacent seats were found, false
∗ otherwise
∗/
public boolean twoTogether()
{ /∗ to be implemented in part (b) ∗/ }
/∗∗ Return the lowest seat number in the specified row for a
∗ block of empty adjacent seats. If no such block exists,
∗ return –1.
∗ @param row the row number
∗ @param seatsNeeded the number of adjacent empty
seats needed
∗ @return lowest seat number for a block of needed
adjacent
∗ seats or –1 if no such block exists ∗/
public int findAdjacent(int row, int seatsNeeded) { /∗ to be implemented in part (c) ∗/ }
//There may be instance variables, constructors, and methods
//that are not shown.
}
(a) Write the Show method isAisleSeat, which should return true if the seat with the specified row and seat number is an aisle seat, false otherwise. Aisle seats are the first and the last columns of the two-dimensional array representing the theater. For example, in the diagram shown above, if show is a Show variable, here are some results of calling the isAisleSeat method.
Method call
show.isAisleSeat(2,5) show.isAisleSeat(0,4)
Return value
true false