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

11.6

时间:2017-11-12 21:47:03      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:mat   sys   generate   ati   int   todo   return   []   string   

package joker;

public class Test_1106 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        TestDemo circle1 = new TestDemo();
        double area=circle1.getArea();
        System.out.println(area);
        TestDemo circle2=new TestDemo(10);
        System.out.println(circle2.getArea());
        System.out.println(circle1.getPerimeter());
        System.out.println(circle2.getPerimeter());
        double ridius=10;
        double areaCircle=Math.PI*ridius*ridius;
        System.out.println(areaCircle);
        circle2.setRadius(5);
        System.out.println(circle2.getArea());
    }

}








package joker;

public class TestDemo {
    private double radius;
    
    public TestDemo(double radius) {
        this.radius = radius;
    }
    public TestDemo() {
        this.radius = 1.0;
    }
    public double getArea() {
        return Math.PI * radius * radius;
    }
    public double getPerimeter() {
        return 2 * Math.PI * radius;
    }
    public void setRadius(double newRadius) {
        this.radius = newRadius;
    }
}



11.6

标签:mat   sys   generate   ati   int   todo   return   []   string   

原文地址:http://www.cnblogs.com/ELF-CH/p/7822771.html

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