/*  This applet allows the user to draw 1 fixed-sized square or 1 fixed-sized circle on a 
canvas.  The program will have 2 buttons, 1 labeled "Square" and the other labeled "Circle".
The user clicks on one of the buttons, then clicks on the canvas, where the appropriate figure
is drawn.  Only 1 object is drawn on the canvas at a time and the user must click on 1 of the
buttons after clicking on the canvas in order to draw another object at a different location.
*/

// or import com.sun.java.swing.*;
//import javax.swing.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
// for the event Mouselistener Interface

public class CircleSquare extends Applet{
        
	Button Button1;	
	Button Button2;
        myCanvas C;

	public void init(){

	/* Add code to initialize, instantiate the 2 buttons and 
	the canvas.  Also, you will need to add the appropriate 
	listeners to each.  Make sure you display C using setVisible(true).
	*/

	}

        class mylistener implements MouseListener{

		/* We're using MouseListeners so you'll need
		to implement all of the methods in that interface. 
		In this case, only the mouseClicked method has any 
		functionality. */

		public void mouseClicked(MouseEvent e){

		/* First, you will need to determine where the event
		is coming from.  Use e.getSource() method to determine
		that.  It returns the handle of the object, either
		Button1, Button2, or C.  If one of the buttons was 
		pressed, use the setSource() method of the mycanvas class
		to keep track of that.  Pass it the argument 1 or 2 depending
		on which button was pressed.  If the mouse clicked on 
		C, then call the setXY() method of the mycanvas class to
		draw the appropriate figure.  Be sure to pass it the argument
		e. */
		
		}

		public void mouseEntered(MouseEvent e){}
		public void mouseExited(MouseEvent e){}
		public void mousePressed(MouseEvent e){}
		public void mouseReleased(MouseEvent e){}
	}

        class myCanvas extends Canvas{
	  private int source;
	  private int x;
	  private int y;

	  public void setSource(int s){
	    source=s;	    	   
	  }

	  public void paint(Graphics g){

	/* Determine if source is greater than 0, which tells you that a button 
	was just pressed.  If so, you need to determine which button by 
	examining the value of source.  If source equals 1, draw a square.
	If source is 2, draw a circle.  To draw the square or circle, you'll
	the drawRect() and drawOval() methods.  Both require 4 arguments.  
	They are: x-coordinate, y-coordinate, width, and height.  All are 
	integers.  Make sure the width and height are equal for both to draw 
	a square and a circle!  For the last step, set source to 0 by calling
	setSource(). */

	  }

	  public void setXY(MouseEvent e){

	/* You'll need to check the value of source to make sure that a button
	was just pressed.  If that is true, use the methods getX() and getY() on
	the event e to determine the x and y coordinates of the mouse click.  
	Assign those values to x and y, respectively, and call the repaint()
	method. */

	  }
	}
}







