Rock paper scissors

Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
Locked
C_daley98
Posts: 11
Joined: Tue Dec 13, 2005 10:37 am

Rock paper scissors

Post 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
Anonymous

Rock paper scissors

Post 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]
Locked