Having problems comparing to objects radius... says double cannot be dereferenced. I'm new to the equals method and greaterThan method so I need some help!
Here is my demo class
public class Circle
{
private double radius;
public Circle(double r)
{
radius=r;
}
public double getArea()
{
return Math.PI * radius * radius;
}
public double getRadius()
{
return radius;
}
public String toString()
{
String str = "The radius is: " + getRadius() + "and the area is: " + getArea(); ;
return str;
}
public boolean equals(Circle circle1)
{
boolean status;
if(getRadius.equals(circle1.getRadius()) && this.getArea().equals(circle1.getArea()))
status=true;
else
status=false;
return status;
}
public boolean greaterThan(Circle circle1)
{
boolean status;
if(getArea().greaterThan(circle1.getArea()))
status=true;
else
status=false;
return status;
}
}
Here is my demo class
public class CircleDemo
{
public static void main(String [] args)
{
Circle circle1 = new Circle(1.44);
Circle circle2 = new Circle(3.22);
System.out.println(circle1);
if(circle1.equals(circle2))
System.out.println("Both objects have the same radius and area.");
else
System.out.println("The objects have different radi and areas.");
if(circle1.greaterThan(circle2))
System.out.println("Circle 1 is greater than circle 2.");
else
System.out.println("Circle 1 is not greater than circle 2.");
}
}