The main program initializes the final scores, starts the game loop where the matches are played, updating the scores appropriately, and then displays the winner.
Once the lower level functions are written and tested, they are ready to be combined to produce the game. The game loop is where the game is played. A point is awarded to the winner of each round and then added to the total for that contestant (computer or player). If the round is a draw, no points are awarded. The player determines how many rounds are to be played by entering the choice of 1, 2, or 3 (1 for Rock, 2 for Paper, 3 for Scissors) or by entering a 0 to end the contest. Once the contest is over, the winner is displayed.
Most of the work has already been completed in the lower level tasks. The main program initializes the final scores, starts the game loop where the matches are played, updating the scores appropriately, and then displays the winner.
Here is a pseudocode
Write ("Rock, Paper, Scissors Tournament")
computerTotal = 0
playerTotal = 0
playerChoice = playerSelection()
while (playerChoice != 0)
computerChoice = computerSelection()
winner = roundWinner(computerChoice, playerChoice)
if (winner == 'computer')
computerTotal = computerTotal + 1
else if (winner == 'player')
playerTotal = playerTotal + 1
playerChoice = playerSelection()
matchWinner(computerTotal, playerTotal)
PYTHON
Step by step
Solved in 3 steps with 1 images