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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 5GZ
icon
Related questions
Question

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 algorithm showing how to set up the game loop:

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

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT