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

Username:   Password: 
 RegisterRegister   
 Assignment in School with loops
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tamir




PostPosted: Mon Jan 07, 2008 6:28 pm   Post subject: Assignment in School with loops

okay first off all to clear things out i just started learning with Turing so yes i am a complete noob at this.

well my question is this... i am doing an security alarm system.. and i want a red flashing circle to appear on my screen changing colours from red to dark red... i know this can be done by using loops but statements/strings and stuff are getting me confused..


View.Set ("graphics")
Draw.FillOval (256, 256, 125, 50, red)
delay (1000)
Draw.FillOval (256, 256, 125, 50, brightred)
loop
end


if anyone can be of assistance please help.. thank you in advance


Tamir
Sponsor
Sponsor
Sponsor
sponsor
HeavenAgain




PostPosted: Mon Jan 07, 2008 6:50 pm   Post subject: RE:Assignment in School with loops

you will need more than 1 delay for it to work
and also the syntax of your "end" it is wrong, because turing doesn't know what to end, so to fix that you use "end loop" obviously it is to end the loop
and now, between your loop and end loop is the things to be "looped" and obviously you have nothing in between to loop, so the "loop" should be placed somewhere you want it to repeat and repeat again. and you are all done Very Happy
Sean




PostPosted: Mon Jan 07, 2008 7:31 pm   Post subject: Re: Assignment in School with loops

Here's a way to do it.

Turing:

%Circle Alarm
View.Set ("graphics")

loop
  Draw.FillOval (256, 256, 125, 50, red)
  delay (1000)
  Draw.FillOval (256, 256, 125, 50, brightred)
end loop


To properly understand the loops, I suggest searching it if you haven't or ask your teacher. But, from what I can tell, your a beginner to it as you stated, with the loop section, you need to put the loop first, then the code you want to be repeated, then end it with an end loop statement.

This code above will repeat the circle drawings until you exit the program, the delay is obvious, it's setting a time barrier between the two circles.

By the way, there is an alarm code out here that you can check, I'll try to find it for you, then you can look at their example, but not take anything and expand on what you want to be done.
tamir




PostPosted: Mon Jan 07, 2008 7:38 pm   Post subject: Re: Assignment in School with loops

yes thanks a lot to both of you and i will search for those examples and if u can find something more can you please contact me.. this assignment is my year end assignment which i have to do with electronics and programming ... but i am new to programming so thanks !!
Sean




PostPosted: Mon Jan 07, 2008 7:58 pm   Post subject: Re: Assignment in School with loops

Alarm Code! Check this out for the code, download the file and look at the source code for ideas, also be sure to remember the password in the program you enter, or else your computer will shut down.
Sean




PostPosted: Mon Jan 07, 2008 8:02 pm   Post subject: Re: Assignment in School with loops

Turing:

%Circle Alarm
View.Set ("graphics")

loop
  Draw.FillOval (256, 256, 125, 50, red)
  delay (1000)
  Draw.FillOval (256, 256, 125, 50, brightred)
  delay (1000)
end loop


Forgot to add in the last delay, without it, the brightred circle appears quickly then disappears before you know it, with the delay, it sets a second to seeing it and then goes back to the darker red. Sorry about that.
syntax_error




PostPosted: Mon Jan 07, 2008 10:19 pm   Post subject: Re: Assignment in School with loops

Vilament wrote:

Turing:

%Circle Alarm
View.Set ("graphics")

loop
  Draw.FillOval (256, 256, 125, 50, red)
  delay (1000)
  Draw.FillOval (256, 256, 125, 50, brightred)
  delay (1000)
end loop

Forgot to add in the last delay, without it, the brightred circle appears quickly then disappears before you know it, with the delay, it sets a second to seeing it and then goes back to the darker red. Sorry about that.


the point of this area is to HELP no work out every detail of the problem for the user to think of; it spoon feeding the answers and as much as sometimes we want that there is no point to it next time please stop yourself from posting the whole answer
a simple guide is enough and let the user figure out the rest; thus they DO learn something instead of copying the code that you so kindly wrote for them.

just a thought for next time you wish to help people here
[/u][/i]
Sean




PostPosted: Tue Jan 08, 2008 7:37 am   Post subject: Re: Assignment in School with loops

I hope you grasped the concept of loops from the code I wrote, but technically, I gave you the code for that part. There are many ways to jazz it up, adding in the beeping sound, asking the user to lock it up and unlock it.

Many different things you can do, and would like to see you make it happen.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: