import javax.swing.JApplet;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Scanner;
public class HappyWild extends JApplet {
public void init() {
setSize(500,500);
}
public void paint (Graphics canvas) {
System.out.println("Are you feeling happy or wild?");
System.out.println("Type in either 'happy' or 'wild'.");
Scanner keyboard = new Scanner(System.in);
String answer = keyboard.nextLine();
System.out.println("You entered: \"" + answer + "\"");
if (answer.equalsIgnoreCase("wild"))
{
//Draw outline
canvas.setColor(new Color(237,207,159));
canvas.fillOval(100, 50, 200, 200);
canvas.setColor(Color.BLACK);
canvas.drawOval (100, 50, 200, 200);
//Draw eyebrows
canvas.fillRoundRect(150, 80, 40, 10, 8, 16);
canvas.fillRoundRect(215, 80, 40, 10, 8, 16);
//Draw mustache
canvas.drawLine (190, 184, 150, 195);
canvas.drawLine (210, 184, 250, 195);
//Draw lips
canvas.drawArc (163, 190, 32, 20, 360, 180);
canvas.drawArc (195, 190, 32, 20, 360, 180);
//Draw eyelids
canvas.setColor(Color.BLACK);
canvas.drawArc (150, 95, 40, 20, 360, 180);
canvas.drawArc (215, 95, 40, 20, 360, 180);
//Draw nose
canvas.drawLine (200, 125, 200, 165);
canvas.drawArc (192, 175, 16, 4, 180, 180);
canvas.drawArc (208, 170, 8, 4, 90, 180);
canvas.drawArc (184, 170, 8, 4, 99, -180);
//Draw mouth
canvas.drawLine (163, 200, 228, 200);
//Draw eyes
canvas.setColor(Color.WHITE);
canvas.fillOval (155, 100, 25, 20);
canvas.fillOval (220, 100, 25, 20);
canvas.setColor(Color.BLACK);
canvas.drawOval (155, 100, 25, 20);
canvas.drawOval (220, 100, 25, 20);
//Draw irises
canvas.setColor(new Color(158,104,17));
canvas.fillOval (163, 107, 10, 10);
canvas.fillOval (228, 107, 10, 10);
//Draw pupils
canvas.setColor(Color.BLACK);
canvas.fillOval (165, 109, 6, 6);
canvas.fillOval (230, 109, 6, 6);
//Draw eye shine
canvas.setColor(Color.WHITE);
canvas.fillOval (168, 109, 2, 2);
canvas.fillOval (233, 109, 2, 2);
}
else if (answer.equalsIgnoreCase("happy"))
{
// Draw outline
canvas.drawOval (100, 50, 200, 200);
// Draw eyes
canvas.fillOval (155, 100, 10, 20);
canvas.fillOval (230, 100, 10, 20);
// Draw mouth
canvas.drawArc (150, 160, 100, 50, 180, 180);
}
else
System.out.println("incorrect input.");
}
}