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

(a) Write the Contestant method updateLocation, which changes the contestant’s location to have the new row and column numbers.
Complete method updateLocation below.
/∗∗ Changes the location of this contestant to a new row
∗ and column.
∗ @param newRow the new row
∗ @param newCol the new column ∗/
public void updateLocation(int newRow, int newCol)
In parts (b) and (c) you will write two methods of a ContestOrganizer class, whose partial implementation is shown below. A contest organizer keeps track of contestants in a two- dimensional array.
public class ContestOrganizer {
/∗ ∗ the number of rows of contestants ∗ /
public static final int NUM_ROWS = < some integer >;
/∗ ∗ the number of columns of contestants ∗ / public static final int CONTESTANTS_PER_ROW = < some integer >;
/∗ ∗ The two-dimensional array of contestants private Contestant[][] contestants;
/∗∗ Sorts arr in increasing order by score. ∗ P o s t c o ndi t i o n:
∗ – arr sorted in increasing order by score. ∗ – Location of each contestant correctly
∗ /



















































































   569   570   571   572   573