对于类的双重调用的demo

代码如下:

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"+"\t\t"+"Areas");
int temp = 0;
for(int i =1;i<=times;i++,temp=i){
c.setRadious(i);
System.out.println(c.getRadious()+"\t\t"+c.findArea());
}
c.setRadious(temp);
}
}

posted @ 2016-07-28 16:03  caocx  阅读(231)  评论(0编辑  收藏  举报