Page 1 of 1

Rock paper scissors

Posted: Tue Dec 20, 2005 2:47 pm
by C_daley98
Does anyone have a turing program of rock paper scissors or could help me?


Archived topic from Iceteks, old topic ID:4038, old post ID:33138

Rock paper scissors

Posted: Fri May 19, 2006 11:15 pm
by Anonymous
I'll start a rock, paper, scizzors for you. Then you can look at my code and see how it works, then finish it yourself. Do not copy this exactly and hand it in to the teacher. They'd probly know something is up if you copied my code word for word.

Code: Select all

var choice : int
var randChoice := Rand.Int (1, 3)
var yourChoice, compChoice : string

put "(1) Rock (2)Paper (3)Scizzors? " ..
get choice

if (choice = 1) then
    yourChoice := "Rock"
elsif (choice = 2) then
    yourChoice := "Paper"
elsif (choice = 3) then
    yourChoice := "Scizzors"
end if

if (randChoice = 1) then
    compChoice := "Rock"
elsif (randChoice = 2) then
    compChoice := "Paper"
elsif (randChoice = 3) then
    compChoice := "Scizzors"
end if

put ""
put "You chose ", yourChoice, "!"
put "Computer chose ", compChoice, "!"
put ""

if (yourChoice = "Rock") and (compChoice = "Rock") then
    put "Tied!"
elsif (yourChoice = "Rock") and (compChoice = "Paper") then
    put "You lose!"
elsif (yourChoice = "Rock") and (compChoice = "Scizzors") then
    put "You win!"
end if

[code] 

[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:4038, old post ID:35030[/size][/color]