I don't know if I'm properly calling a GOval method. My goal is to create the Target corporation logo but with 5 circles. I'm supposed to have the Target symbol centered in the window and have the number of the circles and dimensions controlled by the named constants.
I'm starting with GOval bigCircle and that is my most outer filled circle in color red. Am I properly incorporating the createFilledCircle method?
I only have three circles so far because we're building off a previous assignment and that assignment only had three circles. Also how does N_CIRCLE fit into the picture?
import acm.program.*;
import acm.graphics.*;
import java.awt.*;
public class TargetSymbol extends GraphicsProgram {
public void run(){
double x = getWidth() / 2;
double y = getHeight() / 2;
GOval bigCircle = createFilledCircle(x - OUTER_RADIUS, y - OUTER_RADIUS, 2 * OUTER_RADIUS, 2 * OUTER_RADIUS);
createFilledCircle.setFilled(true);
createFilledCircle.setColor(Color.RED);
add(createFilledCircle);
GOval middleCircle = new GOval(100, 100, 200, 200);
middleCircle.setFilled(true);
middleCircle.setColor(Color.WHITE);
add(middleCircle);
GOval innerCircle = new GOval(155, 150, 100, 100);
innerCircle.setFilled(true);
innerCircle.setColor(Color.RED);
add(innerCircle);
}
private GOval createFilledCircle(double x, double y, double r, Color color){
GOval circle = new GOval( x-r, x-y, 2 * r, 2 * r);
circle.setColor(color);
circle.setFilled(true);
return circle;
}
private static final int N_CIRCLE = 5;
private static final double OUTER_RADUS = 75;
private static final double INNER_RADIUS = 10;
I would say you have the right idea.
GOval bigCircle = createFilledCircle(x - OUTER_RADIUS, y - OUTER_RADIUS, 2 * OUTER_RADIUS, 2 * OUTER_RADIUS);
createFilledCircle.setFilled(true);
createFilledCircle.setColor(Color.RED);
There is no variable called createFilledCircle, so you can't set it to be filled, or set it's color. We could change it to bigCircle, but that would be redundan, as you're already setting those values in the createFilledCircle() method.
I would just recommend you get rid of those 2 parts altogether, leaving you with:
GOval bigCircle = createFilledCircle(x - OUTER_RADIUS, y - OUTER_RADIUS, 2 * OUTER_RADIUS, 2 * OUTER_RADIUS);
N_CIRCLE, I can only assume represents the number of circles there are. For example, if N_CIRCLE is 5, there's the red outer circle, the white circle inside that, a red circle inside that white circle, etc.
Thus you want to use a loop that creates the circles relative to the amount of circles you have (N_CIRCLE).
e.g.
for(int a = 0; a < N_CIRCLE; a++)
{
Create a circle that is smaller than the outer one
Set it's color/fill etc.
}