
//   STAR0.JAVA
//
//  by CS 120 Winter 2006  1pm class   JHorn instructor

import java.awt.*;

class Star0
	{
	private int points, radius, x, y;

	public Star0(int newX, int newY,int inputPoints, int inputRadius)
		{
		x = newX;
		y = newY;
		points = inputPoints;
		radius = inputRadius;

		}

	public void paint(Graphics g)
		{
		int almostHalf = points/2;
		double angle = almostHalf*2*Math.PI/points;
		Color original_color;
		original_color = g.getColor();
		for (int p = 0; p < points; p++)
			{
			g.drawLine(x + (int)(radius * Math.sin(angle*p)),
				y - (int)(radius * Math.cos(angle*p)),
				x + (int)(radius * Math.sin(angle*(p+1))),
				y - (int)(radius * Math.cos(angle*(p+1))));
			}
		}

	//  This is my simple "inside" method, which essentially uses
	//  a square, of side "radius", with center at x,y, as the
	//  "active area" considered to be "inside" the star.  This is
	//  conservative, since much of the square is not really
	//  inside the star.  See Barry and Larry's "inside" method
	//  below, for a "tighter" active area (a circle).
    public boolean inside_Jeff(int xp, int yp)
        {
           return ( x-radius <= xp &&  xp <= x+radius  &&
                 y-radius <= yp && yp <= y+radius );
         }

    //  This is the authors' "inside" method.  It effectively
    //  uses a circle of radius "radius" centered at the star's
    //  x,y coordinate.  Note that this is "tighter" than the
    //  square used in Jeff's "inside" above.
    public boolean inside(int xp, int yp)
        {
            if ( radius*radius > (x-xp)*(x-xp) + (y-yp)*(y-yp))
                 return true;
                 else return false;
        }

	public void bigger()
		{
		        radius += 1;
		}

	public void smaller()
		{
    	        radius -=1;
		}

	public void more()
		{
		    points += 2;
		}

	public void fewer()
		{
			if(points > 3)
			  points -= 2;
		}

    public void move(int new_x, int new_y)
      {
          x = new_x; y= new_y;
      }
	}















