
-----------------------------------
RyanHB
Tue Oct 20, 2009 8:11 am

jcreator
-----------------------------------
This is the client class. Below the client class I have placed the actual class which is called upon..mutators etc.. I am getting this error message: 

Exception in thread "main" java.lang.NullPointerException
    at Face.(Face.java:19)
    at Face.(Face.java:27)
    at SmileTest.main(SmileTest.java:29)

---------------------------------------------------------

import TerminalIO.*;
import TurtleGraphics.*;
import java.awt.Color;
import javax.swing.JColorChooser;

public class SmileTest {
        
 
    public static void main(String[] args) {
    KeyboardReader reader= new KeyboardReader();
    double x,y, radius;
    int mood=0;
    
    
    //Reds in the Initial x & y Positions 
    x= reader.readDouble("Initial x position: ");
    y= reader.readDouble ("Initial y position: ");

    //Size of the FACE
    radius = reader.readDouble("Set the size of the face: ");
   
    mood= reader.readInt("1= Happy, 2= Sad: " );
    
    // JCreator Colour pad 
    JColorChooser jcc= new JColorChooser();
    Color c = jcc.showDialog (null, "Pick a colour for the face: ", Color.blue );
    
   // Create the Basic Face
    Face smile = new Face(x , y);
    smile.setRadius(radius);
   if (mood==2)
    	smile.setMood(false);
    else
        smile.setMood(true);
    	smile.setColor(c);
    	reader.pause();
    
    smile.draw();
    
    while (true){
    	x=reader.readDouble("New x position: ");
    	y=reader.readDouble ("New y position:" );
    	radius= reader.readDouble("set the size of the face: " );
    	mood=reader.readInt("1= Happy, 2= Sad: " );
    	c=jcc.showDialog(null, "Pick a new colour for the face", Color.blue);
    	smile.erase();
    	smile.setColor(c);
    	smile.setRadius(radius);
    	if (mood==2)
    		smile.setMood(false);
    	else
    		smile.setMood(true);
    	smile.move(x,y);
    	smile.draw();
    }
    }
}


-------------------------
Class with mutators etc.. 

import TurtleGraphics.*;
import java.awt.Color;

public class Face {
	private StandardPen pen;
	private double xPosition, yPosition ;
	private boolean mood;
	private double radius;
	private Color colour;
	
	
        
   
    public Face() {
    xPosition = 0;
    yPosition = 0;   
    radius= 0;
    mood= true;
    pen.setColor(Color.red);
    pen = new StandardPen();
    
    
    }
    
    
   public Face (double x, double y){
   	this();
   	xPosition=x;
   	yPosition=y;
   	
   }
   
   public void draw(){
   	
   	//Draw the outline of the face
   	drawCircle(xPosition, yPosition, radius);
   	//Draw the left, then the right, eye.
   	drawCircle(xPosition - radius /2.5, yPosition +radius /3, radius /4);
   	drawCircle(xPosition + radius /2.5, yPosition +radius /3, radius /4);
   	//Draw the horizontal part of the mouth
   	drawLine(xPosition - radius/3, yPosition - radius/2, xPosition + radius/3, yPosition - radius/2);
   	if (mood==false){
   	
   	//Draw the left smile line
   	drawLine(xPosition - radius /3, yPosition - radius/2,xPosition - radius /3 - 5, yPosition - radius/2+5); 
   	
   	//Draw the right smile line
   	drawLine(xPosition + radius /3, yPosition-radius/2,xPosition + radius /3 +5, yPosition-radius/2+5);
   	}else{
   	
   	//Draw the left frown line
   	drawLine(xPosition - radius /3, yPosition - radius/2,xPosition - radius /3 - 5, yPosition - radius/2-5); 
   	
   	//Draw the right frown line
   	drawLine(xPosition + radius /3, yPosition-radius/2,xPosition + radius /3 +5, yPosition-radius/2-5);
   	}
   }
   
   public void erase (){
   	//Sets the colour to white
   	pen.setColor(Color.white);
   	//Draws so that it covers the old drawing
   	draw();
   	//Returns the new colour (white) to the old colour (whatever it was)
  	pen.setColor(colour);
   }
   
   public void move(double x, double y){
   	xPosition=x;
   	yPosition=y;
   }
   
   private void drawCircle (double x, double y, double r){
   	//Draws the face
   	double side= 2.0* Math.PI * r/120.0;
   pen.setColor(colour);
   	pen.up();
   	pen.move(x+r, y - side/ 2.0);
   	pen.setDirection (90);
   	pen.down();
   	for(int i= 0; i