标签:
代码如下:
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);
}
}
标签:
原文地址:http://www.cnblogs.com/caocx/p/5715163.html