here is my problem with Java:
The My Circle class implements the Shape interface and, therefore, it must implement all the necessary methods. I have a problem with the boolean method contains (Rectangle2D r), which "Checks if the inside of the Form contains the fully specified Rectangle2D". Now Rectangle2D is an abstract class that provides (as far as I know) no method for obtaining the coordinates of the corners of a rectangle. More precisely: "The Rectangle2D class describes a rectangle defined by location (x, y) and dimension (wxh). This class is only an abstract superclass for all objects that store a 2D rectangle. Remains in a subclass."
So how can I solve this?
The following is part of my code:
public class Circle implements Shape
{
private double x, y, radius;
public Circle(double x, double y, double radius)
{
this.x = x;
this.y = y;
this.radius = radius;
}
public boolean contains(double x, double y)
{
if (Math.pow(this.x-x, 2)+Math.pow(this.y-y, 2) < Math.pow(radius, 2))
{
return true;
}
else
{
return false;
}
}
public boolean contains(double x, double y, double w, double h)
{
if (this.contains(x, y) && this.contains(x+w, y) && this.contains(x+w, y+h) && this.contains(x, y+h))
{
return true;
}
else
{
return false;
}
}
public boolean contains(Point2D p)
{
if (this.contains(p.getX(), p.getY()))
{
return true;
}
else
{
return false;
}
}
public boolean contains(Rectangle2D r)
{
}
}