Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-02-2009, 12:26 AM   PM User | #1
youradhere4222
New to the CF scene

 
Join Date: Dec 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
youradhere4222 is an unknown quantity at this point
"Start: applet not initialized" error

EDIT: Posted in the wrong forum.

Here's my code:
Code:
// Lab09GRFX04st.java
// This is the student, starting file for the Lab09GRFX04st assignment.

// The Lab09 practice and graded assignment is open ended.
// No code will be provided in the student, starting file.
// There are also no files with solutions for the different point versions.

// Check the Lab assignment document for additional details.


import java.awt.*;
import java.applet.*;

public class Lab09GRFX04st extends Applet
{
	public void paint(Graphics g)
	{
		Meal order1 = new Meal(g,0,0);						
	}
}

class Tray
{
	public Tray(Graphics g, int x, int y)
	{
		g.setColor(Color.lightGray);
		g.fillRect(x+10,y+100,400,200);
		g.setColor(Color.black);
		g.drawRect(x+25,y+115,370,170);
	}
}

class Utensil
{
	public Utensil(Graphics g, int x, int y)
	{
		g.setColor(Color.gray);
		g.fillRect(x+60,y+200,10,60);
	}		
}

class Fork extends Utensil
{
	private int x;
	private int y;
	
	public Fork(Graphics g, int x1, int y1)
	{
		super(g,x1,y1);
		x = x1;
		y = y1;
		drawFork(g);
	}
	
	public void drawFork(Graphics g)
	{
		g.setColor(Color.gray);
		g.fillRect(x+50,y+185,30,15);
		Polygon prong1 = new Polygon();
		prong1.addPoint(x+50,y+185);
		prong1.addPoint(x+56,y+185);
		prong1.addPoint(x+53,y+165);
		g.fillPolygon(prong1);
		Polygon prong2 = new Polygon();
		prong2.addPoint(x+61,y+185);
		prong2.addPoint(x+67,y+185);
		prong2.addPoint(x+64,y+165);
		g.fillPolygon(prong2);
		Polygon prong3 = new Polygon();
		prong3.addPoint(x+74,y+185);
		prong3.addPoint(x+80,y+185);
		prong3.addPoint(x+77,y+165);
		g.fillPolygon(prong3);
	}
}

class Spoon extends Utensil
{
	private int x;
	private int y;
	
	public Spoon(Graphics g,int x1,int y1)
	{
		super(g,x1,y1);
		x = x1;
		y = y1;
		drawSpoon(g);
	}
	
	public void drawSpoon(Graphics g)
	{
		g.setColor(Color.gray);
		g.fillOval(x+50,y+175,30,40);
	}
}

class Knife extends Utensil
{
	private int x;
	private int y;
	
	public Knife(Graphics g, int x1,int y1)
	{
		super(g,x1,y1);
		x = x1;
		y = y1;
		drawKnife(g);
	}
	
	public void drawKnife(Graphics g)
	{
		g.setColor(Color.gray);
		g.fillArc(x+55,y+165,30,60,90,180);
	}
}
class Napkin
{
	public Napkin (Graphics g, int x, int y)
	{
		g.setColor(Color.white);
		g.fillRect(x+50,y+170,60,100);
		g.setColor(Color.darkGray);
		g.drawLine(x+95,y+170,x+95,y+270);
	}
}

class MainDish
{
	private int x;
	private int y;
	
	public MainDish(Graphics g, int x1, int y1)
	{
		x = x1;
		y = y1;
		g.setColor(Color.white);
		g.fillOval(x+155,y+215,150,50);
		g.setColor(Color.cyan);
		g.drawArc(x+175,y+225,110,30,170,210);
	}
}

class Burger extends MainDish
{
	private int x;
	private int y;
	
	public Burger(Graphics g, int x1, int y1)
	{
		super(g,x1,y1);
		x = x1;
		y = y1;
		drawBun(g);
		drawBurger(g);
	}
	
	public void drawBun(Graphics g)
	{
		g.setColor(Color.orange);
		g.fillArc(x+180,y+180,100,70,0,180);
		g.fillRect(x+182,y+230,96,15);
		
	}
	
	public void drawBurger(Graphics g)
	{
		Color brown = new Color(150,75,0);
		g.setColor(brown);
		g.fillRect(x+185,y+215,90,15);
	}
}

class Cheeseburger extends Burger
{
	private int x;
	private int y;
	
	public Cheeseburger(Graphics g, int x1, int y1)
	{
		super(g,x1,y1);
		x = x1;
		y = y1;
		drawCheese(g);
	}
	
	public void drawCheese(Graphics g)
	{
		g.setColor(Color.yellow);
		Polygon cheese = new Polygon();
		cheese.addPoint(x+195,y+215);
		cheese.addPoint(x+265,y+215);
		cheese.addPoint(x+230,y+225);
		g.fillPolygon(cheese);
	}
}

class Hamburger extends Burger
{
	private int x;
	private int y;
	
	public Hamburger(Graphics g, int x1, int y1)
	{
		super(g,x1,y1);
		x = x1;
		y = y1;
		drawSesameSeeds(g);
		drawLettuce(g);
	}
	
	public void drawSesameSeeds(Graphics g)
	{
		g.setColor(Color.yellow);
		g.fillOval(x+190,y+200,3,3);
		g.fillOval(x+200,y+190,3,3);
		g.fillOval(x+210,y+197,3,3);
		g.fillOval(x+220,y+207,3,3);
		g.fillOval(x+260,y+193,3,3);
		g.fillOval(x+230,y+185,3,3);
		g.fillOval(x+240,y+195,3,3);
		g.fillOval(x+253,y+200,3,3);
		g.fillOval(x+267,y+202,3,3);
		g.fillOval(x+220,y+193,3,3);
	}
	
	public void drawLettuce(Graphics g)
	{
		g.setColor(Color.green);
		Polygon lettuce = new Polygon();
		lettuce.addPoint(x+185,y+215);
		lettuce.addPoint(x+275,y+215);
		lettuce.addPoint(x+285,y+225);
		lettuce.addPoint(x+275,y+220);
		lettuce.addPoint(x+265,y+225);
		lettuce.addPoint(x+255,y+220);
		lettuce.addPoint(x+245,y+225);
		lettuce.addPoint(x+235,y+220);
		lettuce.addPoint(x+225,y+225);
		lettuce.addPoint(x+215,y+220);
		lettuce.addPoint(x+205,y+225);
		lettuce.addPoint(x+195,y+220);
		lettuce.addPoint(x+185,y+225);
		lettuce.addPoint(x+175,y+220);
		g.fillPolygon(lettuce);
	}
}

class Drink
{
	private int x;
	private int y;
	private Color drinkColor;
	
	public Drink(Graphics g, Color c1, int x1, int y1)
	{
		x = x1;
		y = y1;
		drinkColor = c1;
		drawCup(g);
	}
	
	public void drawCup(Graphics g)
	{
		Polygon cup = new Polygon();
		cup.addPoint(x+305,y+190);
		cup.addPoint(x+365,y+190);
		cup.addPoint(x+370,y+80);
		cup.addPoint(x+300,y+80);
		g.setColor(drinkColor);
		g.fillPolygon(cup);
	}
}

class Soda extends Drink
{
	private int x;
	private int y;
	private Color drinkColor;
	
	public Soda(Graphics g, Color c1, int x1, int y1)
	{
		super(g,c1,x1,y1);
		x = x1;
		y = y1;
		drinkColor = c1;
		drawTop(g);
	}
	
	public void drawTop(Graphics g)
	{
		g.setColor(Color.red);
		g.fillRect(x+335,y+25,7,45);
		g.fillRect(x+335,y+25,30,7);
		g.setColor(Color.white);
		g.fillRect(x+295,y+70,80,10);
		g.setColor(Color.black);
		g.drawRect(x+295,y+70,80,10);
	}
}

class CocaCola extends Soda
{
	private int x;
	private int y;
	
	public CocaCola(Graphics g, int x1, int y1)
	{
		super(g,Color.red,x1,y1);
		x = x1;
		y = y1;
		drawCupDesign(g);
	}
	
	public void drawCupDesign(Graphics g)
	{
		g.setColor(Color.white);
		g.drawString("C",x+310,y+100);
		g.drawString("O",x+310,y+110);
		g.drawString("C",x+310,y+120);
		g.drawString("A",x+310,y+130);
		g.drawString(" ",x+310,y+140);
		g.drawString("C",x+310,y+150);
		g.drawString("O",x+310,y+160);
		g.drawString("L",x+310,y+170);
		g.drawString("A",x+310,y+180);
		g.drawOval(x+325,y+85,5,5);
		g.drawOval(x+335,y+100,3,3);
		g.fillArc(x+340,y+36,30,90,180,180);
		g.fillArc(x+340,y+125,27,130,0,180);
		g.setColor(Color.lightGray);
		g.drawArc(x+340,y+36,30,90,270,90);
		g.drawArc(x+340,y+125,27,130,95,85);
		g.drawArc(x+340,y+36,29,90,270,90);
		g.setColor(Color.red);
		g.fillArc(x+340,y+36,20,90,180,180);
		g.fillArc(x+350,y+125,17,130,0,180);
		
	}
}

class Sprite extends Soda
{
	private int x;
	private int y;
	
	public Sprite(Graphics g, int x1, int y1)
	{
		super(g,Color.cyan,x1,y1);
		x = x1;
		y = y1;
		drawCupColor(g);
		drawCupDesign(g);
	}
	
	public void drawCupColor(Graphics g)
	{
		for (int blue = 170; blue <= 210; blue++)
		{
			g.setColor(new Color(0,100,blue));
			g.drawLine(blue+260,81,blue+255,189);
		}
		for (int gr = 160; gr <= 200; gr++)
		{
			g.setColor(new Color(0,gr,0));
			g.drawLine(gr+240,81,gr+245,189);
		}
	}
	
	public void drawCupDesign(Graphics g)
	{
		g.setColor(Color.green);
		g.fillArc(x+340,y+157,20,15,5,170);
		g.fillArc(x+340,y+155,20,15,-5,-170);
		g.setColor(Color.yellow);
		g.fillArc(x+336,y+150,20,15,5,170);
		g.fillArc(x+336,y+148,20,15,-5,-170);
		g.setColor(Color.white);
		g.drawString("S",x+315,y+160);
		g.drawString("p",x+322,y+150);
		g.drawString("r",x+329,y+140);
		g.drawString("i",x+336,y+130);
		g.drawString("t",x+343,y+120);
		g.drawString("e",x+350,y+110);
		
	}
}

class HotDog extends MainDish
{
	private int x;
	private int y;
	
	public HotDog(Graphics g, int x1,int y1)
	{
		super(g,x1,y1);
		x = x1;
		y = y1;
		drawHotDog(g);
	}
	
	public void drawHotDog(Graphics g)
	{
		g.setColor(Color.orange);
		g.fillRect(x+180,y+220,20,20);
		g.fillRect(x+200,y+220,60,20);
		g.fillRect(x+260,y+220,20,20);
		g.fillArc(x+170,y+220,20,20,90,180);
		g.fillArc(x+270,y+220,20,20,270,180);
		g.fillArc(x+180,y+235,100,10,180,180);
		g.fillRect(x+180,y+230,20,20);
		g.fillRect(x+200,y+230,60,20);
		g.fillRect(x+260,y+230,20,20);
		g.fillArc(x+170,y+230,20,20,90,180);
		g.fillArc(x+270,y+230,20,20,270,180);
		g.fillArc(x+180,y+245,100,10,180,180);
		g.setColor(Color.red);
		g.fillArc(x+180,y+224,100,12,180,180);
		g.setColor(Color.white);
		g.fillArc(x+187,y+214,86,10,180,180);
	}
}

class Powerade extends Soda
{
	private int x;
	private int y;
	
	public Powerade(Graphics g, int x1, int y1)
	{
		super(g,Color.blue,x1,y1);
		g.setColor(Color.black);
		g.drawString("POWERADE",x+301,y+120);
		g.setColor(Color.white);
		g.drawString("POWERADE",x+302,y+121);
	}
}

class Meal 
{
	private Utensil utensil;
	private Tray tray;
	private Fork fork;
	private Spoon spoon;
	private Knife knife;
	private Napkin napkin;
	private Hamburger plainBurger;
	private Cheeseburger wCheese;
	private Powerade bigK;
	private Sprite coke;
	private HotDog dog;
	
	public Meal(Graphics g, int x, int y)
	{
		tray = new Tray(g,x,y);
		napkin = new Napkin(g,x,y);
		fork = new Fork(g,x+20,y);
		spoon = new Spoon(g,x,y);
		knife = new Knife(g,x+50,y);
		dog = new HotDog(g,x,y);
		bigK = new Powerade(g,x,y);
		coke = new Sprite(g,x+100,y);
	}	
}
It compiles; however, once I switch to the HTML window and try to run it, a screen appears and the status bar is giving me the "Start: applet not initialized error." Here's my HTML code:
Code:
<APPLET CODE = "Lab09GRFX04st.class" WIDTH=1000 HEIGHT=650>

</APPLET>
Does anyone know what's wrong?

Last edited by youradhere4222; 12-02-2009 at 01:15 AM..
youradhere4222 is offline   Reply With Quote
Old 12-02-2009, 12:49 AM   PM User | #2
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
It won't work in 'JavaScript' because it is a 'Java' program.

Try posting in the correct forum for quicker responses.
jmrker is offline   Reply With Quote
Old 12-02-2009, 01:16 AM   PM User | #3
youradhere4222
New to the CF scene

 
Join Date: Dec 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
youradhere4222 is an unknown quantity at this point
Quote:
Originally Posted by jmrker View Post
It won't work in 'JavaScript' because it is a 'Java' program.

Try posting in the correct forum for quicker responses.
Sorry about the mix-up.
youradhere4222 is offline   Reply With Quote
Old 12-02-2009, 01:31 AM   PM User | #4
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
Thumbs up

Quote:
Originally Posted by youradhere4222 View Post
Sorry about the mix-up.
No problem ... didn't want you to wait forever for a response!
jmrker is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:34 PM.


Advertisement
Log in to turn off these ads.