Animate GOvals (snow) falling down from the sky and pilling up on the ground.

Solution

public class Snow extends GraphicsProgram {

	private RandomGenerator rg = new RandomGenerator();

	public void run() {
		ArrayList<GOval> balls = new ArrayList<GOval>();

		while(true) {
			for(int i = 0; i < balls.size(); i++) {
				GOval ball = balls.get(i);
				if(ball.getY() < getHeight() - 10) {
					ball.move(0, 1);
				}
			}

			if(rg.nextBoolean(0.1)) {
				GOval g = new GOval(10, 10);
				g.setFilled(true);
				add(g, rg.nextInt(getWidth()), -10);
				balls.add(g);
			}

			pause(10);
		}

	}

}