/**本程序包括两个类其第一个类TestCircle1是主类。
* 它唯一的目的就是测试第二个类Circle1
* 使用这种类的程序通常称为是该类的客户(client)
* 运行这个程序时,Java运行系统会调用这个主类的main方法
*
* */
public class TestCircle1 {
public static void main(String[] args){
Circle1 circle1 = new Circle1();
System.out.println("The area of the circle of radius " + circle1.radius + " is "+ circle1.getArea());
Circle1 circle2 = new Circle1(25);{
System.out.println("The area of circle of radius " + circle2.radius + " is " + circle2.getArea());
Circle1 circle3 = new Circle1((double)(0.0+Math.random()));
System.out.println("The area of circle of radius " + circle3.radius + " is " + circle3.getArea());
};
}
}
class Circle1 {
double radius ;
Circle1(){
radius = 1.0;
}
Circle1(double newRadius){
radius = newRadius ;
}
double getArea(){
return radius*radius*Math.PI;
}