need help with graphics
we have a group project over inheritance and compostion. and our groupe chose to use graphics instead of millions of polygons. we cant get the pictures to draw. it gives us a error when we exicut the aplet
Exception in thread "AWT-EventQuee-1" java.lang .NullPointer Exception
here is our code
// Lab25st
// This is the student version of the Lab25 assignment.
// Lab 25 is a very open-ended lab assignment. This student version intentionally provides
// little help. It is your job to demonstrate knowledge of inheritance with this assignment.
import java.awt.*;
import java.awt.event.*;
import java.awt.Image.*;
import java.util.ArrayList;
import java.applet.Applet;
publicclass Lab25Gstextends Applet
{
Graphics g;
Image hair,nose,shoes,body,head,arms,legs;
publicvoid init()
{
hair = getImage(getCodeBase(),"hair.gif");
nose = getImage(getCodeBase(),"nose.gif");
shoes = getImage(getCodeBase(),"shoes.gif");
body = getImage(getCodeBase(),"body.gif");
head = getImage(getCodeBase(),"head.gif");
arms = getImage(getCodeBase(),"arms.gif");
legs = getImage(getCodeBase(),"legs.GIF");
}
publicvoid paint(Graphics g)
{
Clown clown =new Clown(g,hair,nose,shoes,body,head,arms,legs);
}
}
class Mammal
{
Body bodyclass;
public Mammal(Graphics g,Image body,Image head,Image arms,Image legs)
{
bodyclass =new Body(g,0,0,body,head,arms,legs);
}
}
class Humanextends Mammal
{
Hair hairclass;
public Human(Graphics g,Image hair,Image body,Image head,Image arms,Image legs)
{
super(g,body,head,arms,legs);
hairclass =new Hair(g,0,0,hair);
}
}
class Hairextends Applet
{
Image hair;
int x,y;
public Hair(Graphics g,int hairx,int hairy,Image hair)
{
x=hairx;
y=hairy;
g.drawImage(hair,x,y,this);
}
}
class Clownextends Human
{
Shoes shoesclass;
Nose noseclass;
public Clown(Graphics g,Image hair,Image nose,Image shoes,Image body,Image head,Image arms,Image legs)
{
super(g,hair,body,head,arms,legs);
shoesclass =new Shoes(g,0,0,shoes);
noseclass =new Nose(g,0,0,nose);
}
}
class Noseextends Applet
{
Image nose;
int x,y;
public Nose(Graphics g,int nosex,int nosey,Image nose)
{
x=nosex;
y=nosey;
g.drawImage(nose,x,y,this);
}
}
class Shoesextends Applet
{
Image shoes;
int x,y;
public Shoes(Graphics g,int shoesx,int shoesy,Image shoes)
{
x=shoesx;
y=shoesy;
g.drawImage(shoes,x,y,this);
}
}
class Bodyextends Applet
{
Image body;
int x,y;
Head headclass;
Arms amrsclass;
Legs legsclass;
public Body(Graphics g,int bodyx,int bodyy,Image body,Image head,Image arms,Image legs)
{
x=bodyx;
y=bodyy;
headclass =new Head(g,0,0,head);
amrsclass =new Arms(g,0,0,arms);
legsclass =new Legs(g,0,0,legs);
g.drawImage(body,x,y,this);
}
}
class Headextends Applet
{
Image head;
int x,y;
public Head(Graphics g,int headx,int heady,Image head)
{
x=headx;
y=heady;
g.drawImage(head,x,y,this);
}
}
class Armsextends Applet
{
Image arms;
int x,y;
public Arms(Graphics g,int armsx,int armsy,Image arms)
{
x=armsx;
y=armsy;
g.drawImage(arms,x,y,this);
}
}
class Legsextends Applet
{
Image legs;
int x,y;
public Legs(Graphics g,int legsx,int legsy,Image legs)
{
x=legsx;
y=legsy;
legs = getImage(getCodeBase(),"legs.GIF");
g.drawImage(legs,x,y,this);
}
}
Message was edited by:
blacklegion

