Two players have completed a game.
Write a method (or function) named
whoWon to determine the winner!
whoWon receives three parameters in the following order: the score of the first player as an
int, the score of
the second player as an
int, and whether the first player played first as a
If either player scored more points than the other, they are the winner! However, if both players tie, then the player that played second is the winner.
Return the result of the game as an
You should return
1 if Player 1 won and
2 if Player 2 won.
If you have solved this problem previously without writing a method, you may reuse your old code!
However, you may try to eliminate the
winner variable that we used previously.
Stuck? You may find these lessons helpful: