Help with ROck paper sicosser game
Author |
Message |
mains50
|
Posted: Wed Apr 07, 2010 9:40 pm Post subject: Help with ROck paper sicosser game |
|
|
What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>
What is the problem you are having?
I need help with display High Score with top score name. I have done the whole game program but i have trouble with the coding of high score and top score name. Basically this game is about you have to play the computer when you lose 5 times you exist.
Describe what you have tried to solve this problem
I have tried different kind of code but all failed
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
the file ics20.t code:
% Extra procedures and functions to be used in ICS2O
% Programmed by: Ridout
% March 2010
%Converts R, P or S to Rock, Paper or Scissors
%For example, put RPSFullName('R') will output "Rock"
%Param: choice character choice (R, P or S)
%Return full name: Rock, Paper or Scissors
function RPSFullName (choice : char) : string
if choice = 'R' then
result "Rock"
elsif choice = 'P' then
result "Paper"
elsif choice = 'S' then
result "Scissors"
else
result "Error"
end if
end RPSFullName
Turing: |
% The following is the rock, paper, and scissor game
% Progammed by: Hassan Zaidi
% Date march 29 / 2010
include "ics2o.t"
% Declare the variables and set their initail
var name : string
var choice : char
var computerChoice : char
var noOfWins : int := 0
var topScore : int := 0
var topScoreName : string
var lowestScore : int := 0
var score : int := 0
var noOfLoss : int := 0
%Display the title
put "Welcome to rock, paper, and scissor game"
put ""
% The Following loop will be the game of
% rock, paper and scissor also claculate wins and loss.
put "Please enter your frist and last name:" ..
get name : *
loop
computerChoice := "RPS" (Rand.Int (1, 3))
put "Please enter your choice (R, P or S): " ..
loop
choice := Str.Upper (getchar)
exit when choice = 'R' or choice = 'P' or choice = 'S'
end loop
put RPSFullName (choice )
put "Computer choice is: ",
RPSFullName (computerChoice )
if computerChoice = choice then
put "You tied"
elsif choice = 'R' and computerChoice = 'S' or
choice = 'P' and computerChoice = 'R' or
choice = 'S' and computerChoice = 'P' then
put "You win"
noOfWins := noOfWins + 1
else
put "You loss"
noOfLoss := noOfLoss + 1
end if
% Exist the loop when wins is are 5
exit when noOfLoss = 5
%Update the highest and lowest score
if noOfWins< lowestScore then
lowestScore := noOfWins
end if
if noOfWins > topScore then
topScore := noOfWins
end if
% Update the highestscore
end loop
% display the lowest, highest, number of wins
put "The number fo wins is: ", noOfWins
put "the number of loss is: ", noOfLoss
|
Please specify what version of Turing you are using
4.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TerranceN
|
Posted: Wed Apr 07, 2010 11:41 pm Post subject: RE:Help with ROck paper sicosser game |
|
|
You need to be more clear with your question. Are you trying to save the top score and name? If so look at The Turing Walkthrough, and look for file input/output. |
|
|
|
|
|
|
|