package com.atguigu.exercise;
public class PassObject {
public static void main(String[] args) {
Object t = new Object();
Circle c = new Circle();
t.printAreas(c, 5);
System.out.println("now radius is " + c.radius);
}
}
class Object{
public void printAreas(Circle c, int time) {
System.out.println("Radius \t \t Area");
// 设置圆的半径
for (int i = 1; i <= time; i++) {
c.radius = i;
System.out.println(c.radius + "\t\t" + c.findArea());
}
c.radius = time + 1;
}
}
class Circle {
double radius;// 半径
// 求圆的面积
public double findArea() {
return Math.PI * radius * radius;
}
}