Computer Science Canada

timer

Author:  susan_101 [ Thu Jan 20, 2005 8:22 pm ]
Post subject:  timer

umm how would i create a timer that stops my program after like a minute or something liek that Sad heelp

Author:  Cervantes [ Thu Jan 20, 2005 8:37 pm ]
Post subject: 

code:

loop
  exit when Time.Elapsed > (1000 * 60) %1000 milliseconds per second.  60 seconds per minute.
end loop

Author:  susan_101 [ Thu Jan 20, 2005 8:52 pm ]
Post subject: 

hmm but this part of the program doesnt happen until later so wouldn't time.elpased not be accurate..i mean what if the user gets to this part around 30 seconds and the timer woul dbe 30 seconds ahead already :/

Author:  Andy [ Thu Jan 20, 2005 8:53 pm ]
Post subject: 

post some code so we have something to work with plz

Author:  susan_101 [ Thu Jan 20, 2005 8:57 pm ]
Post subject: 

code:





randint (random3, 1, 3)
var answer : int
var random : int
var random2 : int
var reply : string



loop
   
    locate (1, 1)
   
    randint (random, 1, 12)
    randint (random2, 1, 12)

    put random, "*", random2

    loop
        locate (3, 1)
        get answer
        if answer not= random * random2 then
            put "Wrong, deducting money"
            locate (3, 1)
            put "       "
            locate (5, 1)
            put "         "
        else
            locate (3, 1)
            put "        "
            locate (4, 1)
            put "                "
            put "Caught it"
            exit
        end if
    end loop

     
end loop

Author:  susan_101 [ Thu Jan 20, 2005 8:58 pm ]
Post subject: 

basically its a math game and theh user only has a certain amount of time to do it until time runs out

Author:  Andy [ Thu Jan 20, 2005 8:59 pm ]
Post subject: 

Oooo then u'd need a clock to do it... type clock, then press F9 in the turing editor.. if u still have trouble, post your new code and then we'll help you through it

Author:  susan_101 [ Thu Jan 20, 2005 9:00 pm ]
Post subject: 

aite t ill try it out

Author:  susan_101 [ Thu Jan 20, 2005 9:02 pm ]
Post subject: 

nvm i got it thznk


: