/**
*
*/
public void updateScore()
{
String str = "Score\tName\n";
for (int i=0; i<players.size(); i++)
{
str += ((Player) players.get(i)).toString() + "\n";
}
gui.setPlayersList(str);
}
2.
Write the documentation comments for the method below,
following the pseudocode standard.
/**
* Return an array of winners. It looks at all the scores, and gets
* the players
* with the highest score.
*
* @return an array of players representing the winners
*/
public Player[] getWinners()
{
Player player;
Vector winners = new Vector();
winners.add(players.get(0));
for (int i=1; i<players.size(); i++)
{
player = (Player) players.get(i);
if (player.getScore() > ((Player) winners.get(0)).getScore())
{
winners = new Vector();
winners.add(player);
}
else if (player.getScore() == ((Player) winners.get(0)).getScore())
{
winners.add(player);
}
}
Player wins[] = new Player[winners.size()];
winners.toArray(wins);
return wins;
}
WHILE deck is not empty
Assign card at start of the deck to each player
Decrement number of cards on the deck
END WHILE
Set each player's hand with distributed cards
/**
* Add a correctly guessed letter to user's word.
* That is, place the user's correct guess in its
* proper position in the user's word. If it occurs more
* than once, do ALL occurrences.
* @param hiddenWord the word the player is trying to guess.
* @param letter the player's guess.
* @param userWord the buffer containing correctly guessed letters.
* @pre letter is in the hidden word.
* @post userWord is updated with letter in each correct position
*/
private void addLetter(String hiddenWord, char letter, StringBuffer userWord)
/** Evaluate a poker hand for a pair - 2 cards of equal rank.
If the hand contains more than one pair, find the first (lowest) one.
@param cards a List of the five cards in the hand.
@pre cards is ordered by rank from low to high.
@return a list containing the two cards of the pair if they exist,
otherwise return an empty list.
*/
public Hand getPair(List cards)