当前位置:首页 > 新闻中心 > 正文

DoubleCircle(doubleclick官网)

摘要: 1、package comjavapublic class Circle final double PI = 36 final...

1、package comjavapublic class Circle final double PI = 36 final double r final可要可不要,看你的圆是不是定死了,final修饰的变量只能初始化一次,不能修改 Circle thisr =10如果默认是在上面,可以定义 double r =1 Circledouble r thisr = r;publicCircledouble r=1 radius=r virtual double Area return PI*radius*radius class Cylindius public Circle protecteddouble heightpublicCylindiusdouble r=1, double h=10Circler height=h double Bulk return PI*radius*radius*height void;供参考 public class Circle public Circledouble cx, double cy, double r centerX = cx centerY = cy radius = r public Circle this0, 0, 0 public void setCenterdouble cx, double cy centerX = cx centerY = cy。

DoubleCircle(doubleclick官网)

2、引入包类我还没有学,不好意思希望对你有助class Cicle定义圆类 double areadouble r定义方法计算圆的面积 return 314*r*r class Test5 public static void mainString args Cicle c=new Ciclenew一个对象carea30;includeltstdioh includeltconioh includeltmathh includeltstringh includeltstdlibh definePI36 const char* menu = quot菜 单quot,quot1三角面积quot,quot2圆的面积quot,quot3退出计算quotdouble trangleAreadouble a, double b, double cdouble circleAreadouble radiusint。

3、public class GetColumnInfo public static void mainString args double circleArea = getCirclSquare10圆的面积 double columnVolumn = getColumnVolumn10,2圆柱的体积 double columnArea = getColumnArea10,2圆柱的表面积 根据半径返回圆的面积 public static。

4、public Circledouble r thisr = r public double getR return r public void setRdouble r thisr = r 面积 return public double getArea return MathPI * Mathpowr, 2 周长 return public double getLong return MathPI * r。

DoubleCircle(doubleclick官网)