Vous êtes sur la page 1sur 2

Module Main

Declare Integer compCounter


Declare Integer playerCounter
Call intro()
If compCounter == 3 OR playerCounter == 3 Then
Call getScore(Integer compCounter, Integer playerCounter)
Else
Call determineWinner(Integer compCounter, Integer playerCounter)
End If
End Module
Module determineWinner(Integer compTotScore, Integer playerTotScore)
Declare String Choices[3] = Rock, Paper, Scissors
Set compChoice = random(1,3)
While compCounter != 3 AND playerCounter != 3 Then
Set player = False
While player == False Then
Display Choose one: Rock, Paper, or Scissors
Input player
If player == Rock Then
Call rockUser(compChoice, compTotScore, playerTotScore)
Else If player == Paper Then
Call paperUser(compChoice, compTotScore, playerTotScore)
Else If player == Scissors Then
Call scissorsUser(compChoice, compTotScore, playerTotScore)
Else
Display Invalid play. Please enter a valid choice of Rock, Paper.
Display or Scissors.
Set player = False
Set compChoice = random(1,3)
End If
End While
Else
Return compCounter, playerCounter
End While
End Module
Module getScore(Integer compScore, Integer playerScore)
If compScore == 3 Then
DisplaySorry, you lose. The score was, compScore
Display to, playerScore, try again next time!
Else
Display Congratulations! You win. The score was, playerScore
Display to, compScore
End If
End Module
Module intro()

Display This program consists of the game of Rock, Paper, Scissors.


Display You will be facing against an AI opponent in a best of 3 series.
Display Draws will result in no points gained and will lengthen the series for each one.
End Module
Module rockUser(String compPick, Integer playerCount, Integer compCount)
If compPick == Rock Then
DisplayThe round is a draw
Else If compPick == Paper Then
DisplayThe computer wins the round.
Set compCount = compCount + 1
Else
Display The player wins the round.
Set playerCount = playerCount + 1
End If
Return compCount, playerCount
Module paperUser(String compPick, Integer playerCount, Integer compCount)
If compPick == Paper Then
DisplayThe round is a draw
Else If compPick == Scissors Then
DisplayThe computer wins the round.
Set compCount = compCount + 1
Else
Display The player wins the round.
Set playerCount = playerCount + 1
End If
Return compCount, playerCount
Module ScissorsUser(String compPick, Integer playerCount, Integer compCount)
If compPick == Scissors Then
DisplayThe round is a draw
Else If compPick == Rockr Then
DisplayThe computer wins the round.
Set compCount = compCount + 1
Else
Display The player wins the round.
Set playerCount = playerCount + 1
End If
Return compCount, playerCount
Call main()

Vous aimerez peut-être aussi