What is the radius of each circle?
The drawing area has a height of 150. What is the Y coordinate of the top of all the squares?
The radius of each circle is half of its diameter.
The horizontal line across the center of the area is at Y=150/2. The top of the squares should be radius pixels above that, or at 150/2 - diameter/2 (remember that Y increases going down.)
So now we have the (X, Y) coordinates of the upper left corner of each of the ten squares: The left edges of the squares are at
X=0, diameter, 2*diameter, 3*diameter, . . . . 9*diameter
and all the Y values are at 150/2 - radius.
The X and Y in the above are local variables for exclusive use of the
paint
method.
It is correct to declare them as is done here.
The blanks should be filled in with arithmetic expressions that use
identifiers, not integer literals like 10, 150, 300 and so on.
Fill in the blanks. (Hint: make use of count
in computing a new X
for each loop iteration.)