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

Username:   Password: 
 RegisterRegister   
 Puzzle
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hydraweapon




PostPosted: Sat Jun 04, 2005 3:01 pm   Post subject: Puzzle

hey guys, i have a problem. i am supposed to make a puzzle where the person clicks on one box and then on another if both pictures are the same they stay open, otherwise they close. i already made the twelve boxes, but i dont know how to randomize the pictures so that they all would be in different spots so 6 pics and u have to put each pic twice
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Sat Jun 04, 2005 9:45 pm   Post subject: (No subject)

You would use arrays, and Rand.Int() commands. Probably also include some counters, so you know how many of each pic are allocated.

Check out the Tutorials for info on how to use all the above if you're not sure.
hydraweapon




PostPosted: Sun Jun 05, 2005 10:09 am   Post subject: (No subject)

also i was wondering if there is a command in turing where you can goto certain line in a program, just like in c
[Gandalf]




PostPosted: Sun Jun 05, 2005 11:09 am   Post subject: (No subject)

You shouldn't need goto command in Turing. They're completely not neccessary. Post what you would like to do and I am sure mostly anyone will tell you there is different - better - solution.

Could this be what uou want?
code:
var number : int
procedure goodnumber
    put "Good job, ", number, " is in the specified range!"
end goodnumber
put "Enter a number 1-4"
get number
if number > 4 then
    put "Too high"
else
    goodnumber
end if

The use of the procedure is completely pointless, but it's to show you. If theat's what you want then look up the tutorial on procedures.
hydraweapon




PostPosted: Sun Jun 05, 2005 11:55 am   Post subject: (No subject)

no its just if my program is very long and i want it to jump from one line to another and it would be easier if i use gotos
[Gandalf]




PostPosted: Sun Jun 05, 2005 12:00 pm   Post subject: (No subject)

Not sure what you mean... If you just want to skip a part of the code when something happens then use an if statement.
code:
if condition then
   code
end if

so if the conditions are not met then the code is executed.

If you really need goto then I am pretty sure there is a tutorial on "faking the goto line in Turing" or something like that.
Bacchus




PostPosted: Sun Jun 05, 2005 6:22 pm   Post subject: (No subject)

If you need to 'goto' a line in Turing, either loop it around or make what you need more then once into a procedure. That way the procedure can be used as many time as you need, then you can add in parameters to make the procedure change for what is needed of it.
1of42




PostPosted: Sun Jun 05, 2005 7:23 pm   Post subject: Re: Puzzle

hydraweapon wrote:
hey guys, i have a problem. i am supposed to make a puzzle where the person clicks on one box and then on another if both pictures are the same they stay open, otherwise they close. i already made the twelve boxes, but i dont know how to randomize the pictures so that they all would be in different spots so 6 pics and u have to put each pic twice


I'm not sure how to do this in Turing, but I did something similar in Java, through the use of Vectors, pseudocode for the loading of the pictures goes something like this:

Put 2 of each picture in the vector.
Get a random int(index) from 0 to the length of the vector
Use the picture at that index, then remove it afterwards.

I'm not sure how to do this in Turing - I don't know of an analogous construct to a Vector.

By the way, goto statements = VERY BAD. If you're using them, you're doing something wrong. Smile
Sponsor
Sponsor
Sponsor
sponsor
hydraweapon




PostPosted: Sun Jun 05, 2005 8:06 pm   Post subject: (No subject)

alright thanx for your advice, this is wat i got so far:


New WinZip File.zip
 Description:

Download
 Filename:  New WinZip File.zip
 Filesize:  49.23 KB
 Downloaded:  144 Time(s)

Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: