import objectdraw.*;import java.awt.*;public class Tree extends ActiveObject {    // # of leaves to generate    private static final int NUM_LEAVES = 150;        // the canvas    private DrawingCanvas aCanvas;             // pictures of a leaf    private Image leafPic;         // Dimensions of screen    private int aScreenWidth, aScreenHeight;        // used to generate random speeds and positions for leaves    private RandomIntGenerator leafLocGen;        // used to generate random speeds and positions for leaves    private RandomDoubleGenerator leafSpeedGen;        // Remember parameters and create random number generators    // in order to create leaves     public Tree( Image aLeafPic,            int screenWidth, int screenHeight,            DrawingCanvas canvas) {                aCanvas = canvas;        leafPic = aLeafPic;        aScreenWidth = screenWidth;        aScreenHeight = screenHeight;                leafLocGen = new RandomIntGenerator( 0, screenWidth);        leafSpeedGen = new RandomDoubleGenerator( 2, 5);                start();    }        // Successively create leaves which will fall     // to ground    public void run() {        RandomIntGenerator picker = new RandomIntGenerator(0,2);        for (int treeCount = 0;                treeCount < NUM_LEAVES;        treeCount++) {            // create a leaf            int next = picker.nextValue();            if (next == 0) {                new FallingLeaf( aCanvas, leafPic,                                 leafLocGen.nextValue(),   // x coordinate                                 leafSpeedGen.nextValue(), // y speed                                 aScreenHeight);            } else if (next == 1) {                new FallingSleet(aCanvas,                                 leafLocGen.nextValue(),                                    leafSpeedGen.nextValue() * 2,                                  aScreenHeight);            } else {                new FallingTomato(aCanvas,                                 leafLocGen.nextValue(),                                    leafSpeedGen.nextValue() * 2,                                  aScreenHeight);            }            pause( 900);                    }    }    }
