• 0

[Java] Help!


Question

7 answers to this question

Recommended Posts

  • 0
except for the slightly poorly laid out instructions.

i found those instructions pretty lame as well. of course I'm almost drunk. But at least I can type :)

Link to comment
Share on other sites

  • 0

I have this so far

import  java.awt.*;

import  java.applet.*;

/*

* Created on Oct 1, 2004

*

* To change the template for this generated file go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

/**

* @author Isaak

*

* To change the template for this generated type comment go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

public class Exercise4a extends Applet{

/*

  Applet description

*/

public void paint(Graphics graphics){

  Point myPoint = new Point();

  Door doorOne = new Door();

  Door doorTwo = new Door();

  Door doorThree = new Door();

 

  doorOne.drawOne(graphics);

  doorTwo.drawTwo(graphics);

  doorThree.drawThree(graphics);

}

}

In one class file and the following in another class file

import java.awt.*;

/*

* Created on Oct 1, 2004

*

* To change the template for this generated file go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

/**

* @author Isaak

*

* To change the template for this generated type comment go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

public class Door{

public Door(Point myPoint){

  Point thePoint = new Point();

 

}

public void drawOne(Graphics graphics){

  //draw doorOne

  graphics.drawRect(10,10,10,10);

 

}

public void drawTwo(Graphics graphics){

  //draw doorTwo

  graphics.drawRect(10,10,20,10);

 

}

public void drawThree(Graphics graphics){

  //draw doorThree

  graphics.drawRect(10,10,30,10);

 

}

}

I can get the boxes to draw but i can't get them to respond to the Point stuff :( Help would be Appreciated

Link to comment
Share on other sites

  • 0
import  java.awt.*;
import  java.applet.*;
/*
* Created on Oct 1, 2004
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/

/**
* @author Isaak
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class Exercise4a extends Applet{
/*
  Applet description
*/
public void paint(Graphics graphics){
  //Point myPoint = new Point();
  Point myPoint = new Point(1,2);
  Door doorOne = new Door(myPoint);
  Door doorTwo = new Door(myPoint);
  Door doorThree = new Door(myPoint);

  doorOne.drawOne(graphics);
  doorTwo.drawTwo(graphics);
  doorThree.drawThree(graphics);
}
}

In one class file and the following in another class file

import java.awt.*;
/*
* Created on Oct 1, 2004
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/

/**
* @author Isaak
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class Door{
Point thePoint;
public Door(Point myPoint){
//Set thePoint 
}
public void drawOne(Graphics graphics){
  //draw doorOne
//Draw rectangle with x and y set to x and y from thePoint 
}
public void drawTwo(Graphics graphics){
  //draw doorTwo
//Draw rectangle with x and y set to x and y from thePoint 

}
public void drawThree(Graphics graphics){
  //draw doorThree
//Draw rectangle with x and y set to x and y from thePoint 

}

}

Link to comment
Share on other sites

  • 0

this code gives me an error?

I however am not sure what it means can someone please clarify

java.lang.InstantiationException: Door

load: Door.class can't be instantiated.

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

nvm i am retarded lol

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.