Now we are studying how to use several classes in Java, and there is a project offering to create a class Circlethat will contain radiusand diameter, and then refer to it from the main class to find the diameter. This code continues to receive an error (mentioned in the header)
public class Circle
{
public CircleR(double r)
{
radius = r;
}
public diameter()
{
double d = radius * 2;
return d;
}
}
Thanks for any help, -AJ
Update 1 : Good, but I didn’t have to declare the third line public CircleR(double r)as double, right? In the book I am studying, example does not do this.
public class Circle
{
public Circle(double r)
{
radius = r;
}
public double area( )
{
double a = Math.PI * radius * radius;
return a;
}
public double circumference( )
{
double c = 2 * Math.PI * radius;
return c;
}
public double radius;
}
, public Circle(double r).... , public CircleR(double r)? - , , , .