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

∗ ∗
Postcondition: Contestant with highest score in row[k] is
in the rightmost column of row[k], 0<=k<NUM_ROWS.
∗/
public void sortAllRows()
(c) Write the Contestant method findWinnerName, which returns the name of the contestant with the highest score. For example, if the contestants are as shown above, a call to findWinnerName should return “Harry”.
When writing findWinnerName, you should assume that the contestants have not yet been sorted by score, and that there is only one contestant with the highest score. In writing your solution, you must use method sortAllRows. You may assume that sortAllRows works as specified, regardless of what you wrote in part (b).
Complete method findWinnerName below.
/
∗∗ ∗
∗ ∗
∗
∗ ∗/
Returns name of contestant with highest score.
Precondition:
– Contestants have not been sorted by score. – Top score is unique.
– Only one contestant has the highest score. @return name of contestant with highest score
public String findWinnerName()
4. Consider the hierarchy of classes shown for a small part of a bird sanctuary.
















































































   572   573   574   575   576