
/**
 * @(#)Forest.java
 *
 * Forest Applet application
 *
 * @author Ben Worwa
 * Project Trees
 * @version 1.00 2012/7/16
 * URL:
 * http:/.......
 *
 */

import java.awt.*;
import javax.swing.*;
import java.util.*;

public class ForestTemplate extends JApplet { 

    // add  declarations
    Random r;
    public void init() {

        // paint background color

    }// end init

    //Method that builds a tree based on random x and y coordinates and random color
    public void paintTree( Graphics g, int x, int y, Color treeColor){

        g.setColor(new Color(130,57,20));
        g.fillRect(x+15,y+30,20,30);
        
        g.setColor((treeColor));
        g.fillOval(x,y,50,50);
        
       
       

    }//end paintTree

    public void paint(Graphics g) {
        super.paint(g);
        
        r = new Random();
        //You can write a loop instead of repeating the lines below

        Color treeColor = new Color(r.nextInt(256),r.nextInt(256),r.nextInt(256));//generate random color for tree
        g.setColor(treeColor);
        int x=r.nextInt(400);          //generate random x coordinate
        int y=r.nextInt(400);          //generate random y coordinate
        
        paintTree(g,x,y,treeColor);            //call to build tree #1
        
         treeColor = new Color(r.nextInt(256),r.nextInt(256),r.nextInt(256));//generate random color for tree
        g.setColor(treeColor);
         x=r.nextInt(400);          //generate random x coordinate
         y=r.nextInt(400);          //generate random y coordinate
        
        paintTree(g,x,y,treeColor);            //call to build tree #1
        
        paintTree(g,x,y,treeColor);            //call to build tree #2
        
         treeColor = new Color(r.nextInt(256),r.nextInt(256),r.nextInt(256));//generate random color for tree
        g.setColor(treeColor);
         x=r.nextInt(400);          //generate random x coordinate
         y=r.nextInt(400);          //generate random y coordinate
        
        paintTree(g,x,y,treeColor);            //call to build tree #3
        
       
        
        
     
        
        

        
    }//end paint

}