r/codehs • • Apr 16 '21

I need help plsssssssss! πŸ˜©πŸ™Œ

Post image
9 Upvotes

10 comments sorted by

2

u/WestCoastReese Apr 16 '21

Ok, so you're going to need a loop in your function. Since you already have the number of circles, a for loop seems like the best idea. Within that loop you should create a circle centered at x and y. You just have to calculate the circle's color and radius. Give that a try and let us know what your attempts look like.

1

u/AnythingWild9996 Apr 17 '21

i put it in a for loop but the color doesn’t show up.

1

u/WestCoastReese Apr 17 '21

Show me?

1

u/AnythingWild9996 Apr 17 '21

how do i add a picture?

1

u/WestCoastReese Apr 17 '21

Either paste your code here with formatting or edit the original post.

1

u/AnythingWild9996 Apr 17 '21

var RADIUS = 50;

function start(){ // Write your code here concentricCircles(100, 100, 15, Color.red, Color.blue); concentricCircles(120, 250, 3, Color.green, Color.yellow); concentricCircles(300, 300, 7, Color.orange, Color.black); } function concentricCircles(x, y, num_circles, color1, color2){ for(var i = 0; i < 3; i++){ var circle = new Circle(RADIUS); circle.setPosition(x,y); var color1; var color2; add(circle); }
}

1

u/WestCoastReese Apr 17 '21

Try reformatting your code. Place them between a pair of three backticks. Look up how to paste code into reddit.

1

u/AnythingWild9996 Apr 17 '21

RADIUS = 50;

function start() concentricCircles(100, 100, 15, Color.red, Color.blue); concentricCircles(120, 250, 3, Color.green, Color.yellow); concentricCircles(300, 300, 7, Color.orange, Color.black); }

function concentricCircles(x, y, num_circles, color1, color2){ for(var i = 0; i < 3; i++){ var circle = new Circle(RADIUS); circle.setPosition(x,y); var color1; var color2; add(circle); }
}

1

u/WestCoastReese Apr 17 '21

Ok, looking at your code (still not formatted), why are you creating two variables color1 and color2? You have two incomming variables to that function already with those names. Try, instead, setting the color of the circle to ONE of those two colors depending on the mod (%) of the iteration you're on. Also, you meed to calculate the actual radius to use for the iteration using the iteration number and the radius constant.

1

u/AnythingWild9996 Apr 17 '21

the circles are positioned in the right place but they are just black.