码迷,mamicode.com
首页 > 其他好文 > 详细

对于类的双重调用的demo

时间:2016-07-28 16:28:33      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:

代码如下:

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);
}
}

对于类的双重调用的demo

标签:

原文地址:http://www.cnblogs.com/caocx/p/5715163.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!