Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: NOT WORKING!!!!!

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry NOT WORKING!!!!!

     
    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.

    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();
     
        }
    }
    imgur: the simple image sharer

    please help guide me in the right direction by telling me whats wrong.. thanks help is appreciated..


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NOT WORKING!!!!!

    Please copy the full text of the compiler's error messages and post them here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Apr 2012
    Posts
    160
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Default Re: NOT WORKING!!!!!

    You don't have a constructor that allows the parameter you give it. Your Square constructor asks for 4 ints, not just one.

Similar Threads

  1. Working with $
    By whome in forum What's Wrong With My Code?
    Replies: 20
    Last Post: April 11th, 2012, 03:00 PM
  2. Jar not WORKING FOR ANYONE BUT ME!!!!!!!! HELP
    By Java Programmer in forum What's Wrong With My Code?
    Replies: 12
    Last Post: February 18th, 2012, 07:32 AM
  3. Why isn't this working?
    By javapenguin in forum What's Wrong With My Code?
    Replies: 14
    Last Post: January 21st, 2011, 04:08 PM
  4. Cannot seem to get this working
    By OttawaGuy in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 28th, 2010, 03:41 PM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM