These practice problems are designed to get you working with basic graphics. You will not be turning these in or getting checked off — they’re just for you to practice!! Feel free to skip around and experiment.
You will write a program to produce the following figure:
The DrawingPanel has size 300 x 250 and has a yellow background. You should put each problem in a separate method. To have multiple methods draw to the same DrawingPanel object, pass the Graphics object to each of them. That way, they will use the same pen to draw.
- Draw a bear face. The face and ears are orange. The face starts at 50, 50 and is a circle with a diameter of 50. The ears have a diameter of 20 and start at (45, 50) and (85, 50). The eyes are black circles with a diameter of 5. They are each 10 pixels in from the edge of the face’s bounding rectangle. The mouth is a rectangle of size 10 x 3 starting at (70, 85).
- Draw squares using a for loop. The smallest square has size 20 x 20. Each of the next squares is 20 pixels bigger than the last. The diagonal line starts at (150, 50).
- Draw a target. The largest circle is red and starts at (20, 120). Each subsequent circle is 10 pixels smaller in diameter. Colors alternate between red and white.