import javax.swing.*;
import java.awt.*;
import java.util.*;

public class SmileyClass
{
	  private static final int FACE_DIAMETER = 200;
      private static final int X_FACE = 100;
      private static final int Y_FACE = 50;
   
      private static final int EYE_WIDTH = 10;
      private static final int EYE_HEIGHT = 20;
      private static final int X_RIGHT_EYE = 155;
      private static final int Y_RIGHT_EYE = 95;
      private static final int X_LEFT_EYE = 230;
      private static final int Y_LEFT_EYE = Y_RIGHT_EYE;
   
      private static final int Y_NOSE = 135;
   
      private static final int MOUTH_WIDTH = 100;
      private static final int MOUTH_HEIGHT = 50;
      private static final int X_MOUTH = 150;
      private static final int Y_MOUTH = 175;
      private static final int MOUTH_DEGREES_SHOWN = 180;
	
      private int noseDiameter = 10;
      private int xNose = 195;
      private int mouthStartAngle = 180;
		
      /*
       * input: boolean smile
       * smile is true, Smiley smiles
       * smile is false, Smiley frowns
       * */
      private void setMouth(boolean smile)
      {
    	  //use the variable smile (local to this method) to decide how 
    	  //to set the mouthStartAngle
    	  if(!smile) //this is equivalent to if(smile == false)
    		  mouthStartAngle = 0;
    	  //don't need an else statement since mouthStartAngle is initialized to 180

      }
      /*
       * input: Graphics and a String
       * set color to the input String
       * set color to white if incorrect input
       * */
      private void setEyeColor(Graphics canvas, String color)
      {
    	  /*important to use color, not eyeColor variable here
    	    since color is the local variable to this method
    	    that contains the value passed in by the user */
    	  color = color.toLowerCase();
    	  if(color.equals("blue"))
    		  canvas.setColor(Color.BLUE);
    	  else if(color.equals("green"))
    		  canvas.setColor(Color.GREEN);
    	  else if(color.equals("gray"))
    		  canvas.setColor(Color.GRAY);
    	  else
    		  canvas.setColor(Color.WHITE);
      }
		
      /*
       * input: an int
       * resize nose to the magnification of size as long as the size is in the range [1,4]
       * also, centers the nose by changing xNose
       * */
      public void setNoseSize(int s)
      {
    	  //same, or similar if statement to lab 3
    	  //make sure to use the local variable s here
    	  if(s <= 4 && s >= 1){
    		  noseDiameter *= s;
    	  //the following code will center the nose
		  if(s == 2)
			  xNose = 190;
		  else if(s == 3)
			  xNose = 185;
		  else if(s == 4)
			  xNose = 180;
    	  }
    	  
      }
      /*
       * input: graphics and int
       * draws the nose
       * */
      public void drawNose(Graphics canvas)
      {
       //don't need to call setNoseSize from here, since it was called from SmileyMain
  			canvas.setColor(Color.BLACK);
  			canvas.fillOval(xNose, Y_NOSE, noseDiameter, noseDiameter); 	  
      }
      /*
       * input: graphics and boolean
       * calls the private method, setMouth
       * draws mouth
       * */
      public void drawMouth(Graphics canvas, boolean smile)
      {
    	  //be sure to call setMouth here, so that the mouthStartAngle is correct before
    	  //you draw the mouth
    	    setMouth(smile);
  			canvas.setColor(Color.RED);
  			canvas.drawArc(X_MOUTH, Y_MOUTH, MOUTH_WIDTH, MOUTH_HEIGHT, mouthStartAngle, MOUTH_DEGREES_SHOWN);  
      }	
      
      /*
       * input: graphics and String
       * calls the private method, setEyeColor
       * draws the eyes
       * */		
      public void drawEyes(Graphics canvas, String color)
      {
    	  //be sure to call setEyeColor here, so that the eye color is set before you
    	  //draw the eyes
    	  setEyeColor(canvas, color);
    	  canvas.fillOval(X_RIGHT_EYE, Y_RIGHT_EYE, EYE_WIDTH, EYE_HEIGHT);
    	  canvas.fillOval(X_LEFT_EYE, Y_LEFT_EYE, EYE_WIDTH, EYE_HEIGHT);
      }
		
      /*
       * input: graphics
       * draws the face
       * */			
      public void drawFace(Graphics canvas)
      {
    	  //don't need to change the code here at all - already written for you
    	  canvas.setColor(Color.YELLOW);
    	  canvas.fillOval(X_FACE, Y_FACE, FACE_DIAMETER, FACE_DIAMETER);
    	  canvas.setColor(Color.BLACK);
    	  canvas.drawOval(X_FACE, Y_FACE, FACE_DIAMETER, FACE_DIAMETER);	
      }		
}