博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
12 电视机
阅读量:4313 次
发布时间:2019-06-06

本文共 1060 字,大约阅读时间需要 3 分钟。

public class L1106 {    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());    }}
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;    }}

转载于:https://www.cnblogs.com/speater/p/8057206.html

你可能感兴趣的文章
SyntaxError: keyword can't be an expression解决方法
查看>>
高级特性(2)-迭代
查看>>
Android上PhoneGap打包本地网站和在线网站
查看>>
HDU-2052(字符画图问题)
查看>>
jython学习笔记3
查看>>
Web测试
查看>>
模型搭建练习2_实现nn模块、optim、two_layer、dynamic_net
查看>>
使用jQuery开发datatable分页表格插件
查看>>
C语言笔记(枚举)
查看>>
coreseek安装使用
查看>>
苹果电脑提示打不开 因为它来自身份不明的开发者 不能安装下载的苹果软件解决方法...
查看>>
收发ICMP封包,实现ping
查看>>
MySql command line client 命令系列
查看>>
内置函数2
查看>>
扩展 IEnumerable<T>,让它根据另一个集合的顺序来排列
查看>>
mvc4.0添加EF4.0时发生编译时错误
查看>>
第16月第12天 CABasicAnimation 旋转加速
查看>>
Linux下查看Python安装了哪些脚本模块
查看>>
ERROR- 开发常见error
查看>>
Servlet 中文乱码问题及解决方案剖析
查看>>