代码如下:
package cao.com.duixiang;
public class TestCCircle {
public static void main(String[] args) {
PassObjectt op = new PassObjectt();
CircleC cc = new CircleC();
op.printArea(cc, 5);
System.out.println("the now radious is "+cc.getRadious());
}
}
class CircleC{
double radious;
public double findArea(){
return Math.PI*(radious*radious);
}
public double getRadious() {
return radious;
}
public void setRadious(double radious) {
this.radious = radious;
}
}
class PassObjectt{
public void printArea(CircleC c,int times){
System.out.println("times"+" "+"Areas");
int temp = 0;
for(int i =1;i<=times;i++,temp=i){
c.setRadious(i);
System.out.println(c.getRadious()+" "+c.findArea());
}
c.setRadious(temp);
}
}