created 01/01/03

# Chapter 74 Programming Exercises

Note: You may find that appletviewer is a better tool to use with applet graphics than your Web browser.

## Exercise 1

Modify the snowflake method so that different levels of stars are drawn with different colors. Use colors that are all close to pastel blue. Do this by changing the pen color based on the size of the star.

Click here view the solution for this question

## Exercise 2

Implement the blizzard program: draw a few dozen randomly positioned snowflakes of a few random sizes and a few random colors.

Click here view the solution for this question

## Exercise 3

Write a java applet that creates the following figure:

The only drawing method this figure uses is `drawLine()`. The basic figure is a triangle. But rather than draw the full sized triangle, draw three half-sized triangles:

• The left vertex of the lower left triangle is the same as the left vertex of the big triangle. Its other two vertices are halfway along the bottom and left sides of the big triangle.
• The right vertex of the lower right triangle is the same as the right vertex of the big triangle. Its other two vertices are halfway along the bottom and right sides of the big triangle.
• The top vertex of the top triangle is the same as the top vertex of the big triangle. Its other two vertices are halfway along the right and left sides of the big triangle.

Write a method `drawTriangle( int CenterX, int CenterY, int side )` that draws a triangle centered at `(CenterX, CenterY)` if `side` is small. Otherwise, it draws three triangles.