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!
[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!
Comment