Override Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StrikeZero
    New Member
    • Nov 2008
    • 1

    #1

    Override Problem

    Hello, I am trying to extend my class Point in class Point2D, but I always get an error that it can not find the symbol Point. This is my code:
    [code=java]
    package Package1DShapes ;// a folder that has class point and class algebra inside

    public class Point
    {
    public int x;

    public Point(int x)
    {
    this.x = x;
    setPoint(x);
    }

    public void setPoint(int x)
    {
    this.x = x;
    getPoint();
    }

    public int getPoint()
    {
    return x;
    }

    public String toString()
    {
    return ("x =" + x);
    }

    public boolean equals(Object otherObject)
    {
    if (otherObject == null)
    {
    return false;
    }
    else if(getClass() != otherObject.get Class())
    {
    return false;
    }
    else
    {
    Point otherPoint = (Point)otherObj ect;
    return(x == otherPoint.x);
    }
    }
    }


    package Package2DShapes ;
    import Package1DShapes .*;

    public class Point2D extends Point
    {
    public int y;

    public Point2D(int x, int y)
    {
    super.setPoint( x);
    setPoint2D(y);
    }

    public void setPoint2D(int y)
    {
    this.y = y;
    getPoint2D();
    }

    public int getPoint2D()
    {
    return y;
    }

    public boolean equals(Object otherObject)
    {
    if (otherObject == null)
    {
    return false;
    }
    else if(getClass() != otherObject.get Class())
    {
    return false;
    }
    else
    {
    Point otherPoint = (Point)otherObj ect;
    Point2D otherPoint2D = (Point2D)otherO bject;
    return(x == otherPoint.x);
    return(y == otherPoint2D.y) ;
    }
    }

    public String toString()
    {
    return ("x =" + x);
    return ("y =" + y);
    }


    }

    [/code]
    Thanks!
    Last edited by Nepomuk; Nov 13 '08, 04:32 PM. Reason: Added [CODE] tags
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    1.) Make sure you are posting in the correct forum next time.
    2.) Use code tags when posting code.
    3.) Your Point.class file needs to be made available on the classpath when you compile your Point2D.java file.

    Comment

    Working...