Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Another Lame Text Game
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Zampano




PostPosted: Mon Sep 17, 2007 8:20 am   Post subject: Another Lame Text Game

Here's my second game in Turing. It took 20 minutes of a boring class to make.
It could be hard if you have no strategy.
I hope you enjoy.
Turing:

var num,guess,tries,win:int
loop   
    win:=0
    tries:=7
    num:=Rand.Int(1,100)
    put "Guess the number between 1 and 100 in seven tries."
    loop
        get guess
        if guess>num and guess<101 then
            tries:=tries-1
            put "You guessed too high!"
            if tries>0 then
                put "Try again. You have ",tries," tries left."
            end if
        elsif guess<num and guess>0 then
            tries:=tries-1
            put "You guessed too low!"
            if tries>0 then
                put "Try again. You have ",tries," tries left."
            end if
        elsif guess=num then
            put "You got it!"
            win:=1
        else
            put "Invalid entry."
        end if
        exit when tries=0 or win=1
    end loop
    if win=1 then
        put "You won!"
    elsif win not=1 then
        put "You lost! Try again."
    end if
   
end loop
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: