cylinder.txt
来自「一个比较好的Java试验」· 文本 代码 · 共 53 行
TXT
53 行
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testcylinder;
/**
*
* @author Administrator
*/
class Circle{
private double radius;
public Circle(){
radius=1.0;
}
public Circle(double radius){
this.radius=radius;
}
public void setRadius(double radius){
this.radius=radius;
}
public double getRadius(){
return radius*radius*Math.PI;
}
}
class Cylinder extends Circle{
private double length;
public Cylinder(){
setRadius(1.0);
length=1.0;
}
public Cylinder(double radius,double length){
super(radius);
this.length=length;
}
public double getArea(){
return getArea()*length;
}
}
public class TestCylinder{
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Cylinder a=new Cylinder();
System.out.println("The volumn is:"+a.getArea());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?