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

Username:   Password: 
 RegisterRegister   
 Number choosing program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic
Author Message
TheSecretWaterBender




PostPosted: Thu Jan 06, 2011 11:41 pm   Post subject: Number choosing program

What is it you are trying to achieve?
Im trying to create a program where the user can click on six numbers and each number is displayed and stored (they can't choose the same number twice)


What is the problem you are having?
I cannot click more than once before the program ends

Describe what you have tried to solve this problem
I tried adding another for statement and have no idea as to storing (preferably in an array) or stopping a number (or range from being clicked twice) efficiently


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:

var count:int:=1
var x,y,b:int
var font1: int := Font.New ("Comicsans:25:bold")
for z:0..6
for q:0..6
Draw.Box (20+z*60,320-q*50,80+z*60,370-q*50,blue)
Font.Draw(intstr(q*7+(z+1)),35+z*60,335-q*50, font1, red)
end for
end for
for z:0..6
for q:0..6
loop
Mouse.Where(x,y,b)
if b = 1
then
if x>20+z*60 and x<80+z*60 and y>320-q*50 and y<370-q*50
then
put q*7+(z+1)," "..
end if
end if
exit when b=1
end loop
end for
end for



Please specify what version of Turing you are using
version 4.1.1
 
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jan 06, 2011 11:44 pm   Post subject: RE:Number choosing program

Can you briefly explain what's going on inside your loop?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
 
TheSecretWaterBender




PostPosted: Thu Jan 06, 2011 11:51 pm   Post subject: RE:Number choosing program

the loop posts the number clicked based on the parameters given (it's a 7x7 grid with numbers from 1-49)
 
TheSecretWaterBender




PostPosted: Sun Jan 09, 2011 12:40 am   Post subject: Re: Number choosing program

I actually found a temporary fix but i am having problems now with being able to click again after they click on the same number twice
 
Tony




PostPosted: Sun Jan 09, 2011 12:42 am   Post subject: RE:Number choosing program

Post the new code that goes along with that question.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
 
TheSecretWaterBender




PostPosted: Sun Jan 09, 2011 12:48 am   Post subject: Re: Number choosing program

woops http://compsci.ca/v3/images/smiles/icon_redface.gif
Turing:

for s:1..6
for z:0..6
for q:0..6
loop
Mouse.Where(x,y,b)
if b = 1
then
if x>20+z*60 and x<80+z*60 and y>320-q*50 and y<370-q*50
then
a(s):=q*7+(z+1)
if s > 1 then
            for p : 1 .. 5
                if p not= s and p < s then
                    if a (s) = a (p) then
                        put "You cannot guess the same number twice"
                        else
                    end if
                end if
            end for
            end if
        Draw.FillBox(20+z*60,320-q*50,80+z*60,370-q*50,blue)
end if
        end if
        exit when b=1
end loop
end for
end for
delay (300)
end for
 
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: