To complete Challenge 49, the following codes must be placed into BlueJ™:
import java.lang.Math;
public class Circle extends Shape
{
private double radius;
public Circle(String name, double r)
{
super(name);
radius = r;
}
public double area()
{
return (Math.PI * radius * radius);
}
public double perimeter()
{
return (2 * radius * Math.PI);
}
}
public class Square extends Shape
{
private double length;
public Square(String name, double ℓ)
{
super(name);
length = ℓ;
}
public double area()
{
return (length * length);
}
public double perimeter()
{
return (length * 4);
}
}
−Phoenix
Outstanding. As a matter of convention, no special chars for variable names. 900 XPs awarded for completion.
ReplyDelete