I have some code here, and i am receiving the the "Cannot find symbol error", its driving me crazy.. my assignment told me to place it in the main method. Is that not the main? (sorry if stupid question, but i am new to java!), i have attempted to move the main method into the other class, but i am still getting the error, then i put under constructor which also doesn't work..sorry i am slightly confused
The code is below.. please take a look!
Thanks for your time.
-ZeZverige
package lab5;
import java.util.*;
import java.awt.*;
import java.applet.*;
public class Lab5 {
abstract class DrawableShape {
private int x;
private int y;
// constructor
DrawableShape(int newx, int newy) {
moveTo(newx, newy);
}
// accessors for x & y
int getX() {
return x;
}
int getY() {
return y;
}
void setX(int newx) {
x = newx;
}
void setY(int newy) {
y = newy;
}
// move the x & y position
void moveTo(int newx, int newy) {
setX(newx);
setY(newy);
}
void rMoveTo(int deltax, int deltay) {
moveTo(getX() + deltax, getY() + deltay);
}
// virtual draw method
abstract void draw();
}
class Square extends DrawableShape {
private int width;
private int height;
// constructor
Square(int newx, int newy, int newwidth, int newheight) {
super(newx, newy);
setWidth(newwidth);
setHeight(newheight);
}
// accessors for the width & height
int getWidth() { return width; }
int getHeight() { return height; }
void setWidth(int newwidth) { width = newwidth; }
void setHeight(int newheight) { height = newheight; }
// draw the square
void draw() {
System.out.println("Drawing a Rectangle at:(" + getX() + ", " + getY() +
"), width " + getWidth() + ", height " + getHeight());
}
}
}
and i have the main also-
package lab5;
public class drawing {
public static void main(String[] args) {
Square sq = new Square(5); // <--------- THIS IS THE ERROR "Square" is redlining.
sq.moveBy(7, 7);
sq.draw();
}
}

New Topic/Question
Reply



MultiQuote





|