• Post Reply Bookmark Topic Watch Topic
  • New Topic

2DG

 
Lloyd Jenkins
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. I'm truly stuck and could do with some help because I can't see what's going wrong.
The errors are simple, but I can't see why they're occuring.
I'm trying to write a small simple program that displays a house upside town and in the corner of a frame and canvas I've created. Each individual java file compiles fine, as does the project as a whole (I've done it in Borland JBuilder), but at runtime it comes up with some errors.
--------
"House.java": Error #:300: class Quad not found in class House at line 4, columnn 28
"Square.java": Error #:300: class Quad not found in class Square at line 4, columnn 28
"SkelApp2DGCanvas.java": Error #:300: constructor House not found in class House at line 15, columnn 19
------
The problem is, in the first two errors the error relates me my lines
'public class House extends Quad' & 'public class Square extends Quad' - they're clearly calling Quad as a parent class, but why is it saying that it need Quad class in its own class?
Why doesn't it like me extending? (I'm using JDK 1.3 btw)
And with the final error, the House constructor is very much present in the House.java (no parameters need passing or anything) as it's not an overloaded method.
None of the java files in question have any other errors, and from what I can see shouldn't throw up these errors.
Any other help would be GREATLY appreciated. But also if anyone would want to look at it themselves directly, pls email me and I'll send it through.
All help is very much appreciated. I'm desperate here
 
Lloyd Jenkins
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've fixed 2 of the problems, it's just this error left.
"House.java": Error #:300: class Quad not found in class House at line 4, columnn 28
I'll post the 2 relevant java files now:
-------
Quad.java
import java.awt.*;
public class Quad
{
protected Point vertices[];
public Quad()
{
super();
vertices = new Point[4];
vertices[0] = new Point(10, 10);
vertices[1] = new Point(50, 250);
vertices[2] = new Point(300, 200);
vertices[3] = new Point(150, 50);
}
public Quad(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
super();
vertices = new Point[4];
vertices[0] = new Point(x1, y1);
vertices[1] = new Point(x2, y2);
vertices[2] = new Point(x3, y3);
vertices[3] = new Point(x4, y4);
}
protected void display(Graphics g)
{
g.drawLine(vertices[0].x, vertices[0].y, vertices[1].x, vertices[1].y);
g.drawLine(vertices[1].x, vertices[1].y, vertices[2].x, vertices[2].y);
g.drawLine(vertices[2].x, vertices[2].y, vertices[3].x, vertices[3].y);
g.drawLine(vertices[3].x, vertices[3].y, vertices[0].x, vertices[0].y);
}
}
-----
House.java
import java.awt.*;
public class House extends Quad
{
public Quad window1, window2, window3, window4, walls, roof, chimney, door;
public Point vertices[];
public House()
{
walls = new Square(250, -125,-125);
roof = new Quad(-125,125, -95,200, 95,200, 125,125);
chimney = new Quad(115,200, 120,200, 120,230, 115,230);
window1 = new Square(50, -105,-105);
window2 = new Square(50, 55,-105);
window3 = new Square(50, -105,105);
window4 = new Square(50, 55,105);
door = new Quad(-15,-75, 15,-125, -15,-125, 15,-75);
}
public void paint(Graphics g)
{
walls.display(g);
chimney.display(g);
window1.display(g);
window2.display(g);
window3.display(g);
window4.display(g);
door.display(g);
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!