All pastes #1593652 Raw Edit

Face

public java v1 · immutable
#1593652 ·published 2009-10-05 03:22 UTC
rendered paste body
import java.awt.Graphics2D;import java.awt.geom.Ellipse2D.Double;import java.awt.geom.Ellipse2D;import java.awt.geom.Arc2D;/** * A class that draws a face. */public class Face{    /**     * Constructs a new face.     * @param x The location of the  top left corner on the x-axis     * @param y The location of the  top left corner on the y-axis     */    public Face(int x,int y)    {        xLeft = x;        yTop = y;    }        /**     * Draws the face.     */    public void draw(Graphics2D g2)    {        //create the head        Ellipse2D.Double headShape = new Ellipse2D.Double(xLeft,yTop,150-change, 150-change);        //create eyes        Ellipse2D.Double eye1 = new Ellipse2D.Double(xLeft+40,yTop+35,25-change,17-change);        Ellipse2D.Double eye2 = new Ellipse2D.Double(xLeft+85,yTop+35,25-change,17-change);        //create pupils                Ellipse2D.Double pupil1 = new Ellipse2D.Double(xLeft+47,yTop+39,10-change,10-change);        Ellipse2D.Double pupil2 = new Ellipse2D.Double(xLeft+92,yTop+39,10-change,10-change);        //create the mouth        Arc2D.Double mouth = new Arc2D.Double(xLeft+35,yTop+80,40-change, 40-change,40,40, Arc2D.OPEN);        //Draw eyes        g2.draw(eye1);        g2.draw(eye2);        //Draw the  head        g2.draw(headShape);        //Draw pupils        g2.draw(pupil1);        g2.draw(pupil2);        //Draw the mouth        g2.draw(mouth);    }    /**     * Moves the face to a new location.     * @param xMove A number specifying how much to move the original x position     * @param yMove A number specifying how much to move the original y position     */    public void move(int xMove, int yMove)    {        xLeft = xMove+xLeft;        yTop = yMove+yTop;    }        /**     * Makes the face shrink by specified amount.     * @param changeAmount The amount to shrink.     */    public void shrink(int changeAmount)    {        change = changeAmount;    }    /**     * Makes the face grow by specified amount.     * @param changeAmount The amount to grow.     */    public void grow(int changeAmount)    {        change = -changeAmount;    }        private int xLeft;    private int yTop;    private int change;}