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 the main method.
imgur: the simple image sharerpackage 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(); } }
please help guide me in the right direction by telling me whats wrong.. thanks help is appreciated..