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

Username:   Password: 
 RegisterRegister   
 Drawing Circrles from left to right, 40 total, random colors
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
moneyhoney




PostPosted: Tue Mar 05, 2013 2:52 pm   Post subject: Drawing Circrles from left to right, 40 total, random colors

Exercise: 5. Draw 40 small circles starting at the middle left of the screen extending to the middle right of the screen. Make each circle a random color.

left question at school, in case you guys know how. I'll write up a new one, editing this thread soon.
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Tue Mar 05, 2013 4:58 pm   Post subject: RE:Drawing Circrles from left to right, 40 total, random colors

Are you asking us to program it for you?
moneyhoney




PostPosted: Tue Mar 05, 2013 7:03 pm   Post subject: Re: RE:Drawing Circrles from left to right, 40 total, random colors

Raknarg @ Tue Mar 05, 2013 4:58 pm wrote:
Are you asking us to program it for you?


No

var circleCount : int
var circleColour : int
var x : int
var y : int

y := maxy div 2
x := 15
circleCount := 0
loop
randint (circleColour, 1, 255)
Draw.FillOval (x, y, 15, 15, circleColour)

circleCount := circleCount + 1
x := x + 15
end loop

I need to know how to make it 40 circles.
evildaddy911




PostPosted: Tue Mar 05, 2013 7:37 pm   Post subject: Re: Drawing Circrles from left to right, 40 total, random colors

the infinite loop will make an infinite amount of circles. do you know how to repeat a fixed number of times?
hint: try a different type of loop
Raknarg




PostPosted: Wed Mar 06, 2013 7:53 pm   Post subject: RE:Drawing Circrles from left to right, 40 total, random colors

or in case they dont know already... Basically every language has a structure called a for loop, which loops for only a specific amount of iterations.

In this case, it's structured like this:

for i : 1 .. n

end for

i being what you want to call the loop, and n being the number of times for it to iterate.
KingGrumpz




PostPosted: Thu Mar 07, 2013 9:49 pm   Post subject: RE:Drawing Circrles from left to right, 40 total, random colors

if you want to keep the code you have use an exit when statement
(Ex. exit when Letter = "a")
Raknarg




PostPosted: Sat Mar 09, 2013 6:17 pm   Post subject: RE:Drawing Circrles from left to right, 40 total, random colors

Or, you know, teach him a much better concept
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  [ 7 Posts ]
Jump to:   


Style:  
Search: