< previous page page_561 next page >

Page 561
Process Plays (In: gameNumber, playForA, playForB; Inout: winsForA, winsForB)
IF playForA == playForB
   Print gameNumber, " is a tie"
ELSE IF playForA == PAPER AND playForB == ROCK OR
        playForA == SCISSORS AND playForB == PAPER OR
        playForA == ROCK AND playForB == SCISSORS
   Record a win for Player A, incrementing winsForA (the number
        of games won by Player A)
ELSE
   Record a win for Player B, incrementing winsForB

Print Big Winner (In: winsForA, winsForB)
Print winsForA
Print winsForB
IF winsForA > winsForB
   Print "Player A has won the most games."
ELSE IF winsForB > winsForA
   Print "Player B has won the most games."
ELSE
   Print "Players A and B have tied."

Conversion Value (In: someChar) Out: Function value Level 2
SWITCH someChar
  'R': Return ROCK
  'P': Return PAPER
  'S': Return SCISSORS

Record A Win (In: player, gameNumber; Inout: numOfWins)
Print message saying which player has won game number gameNumber
Increment numOfWins by 1

 
< previous page page_561 next page >