DoubleCircle(doubleclick官網)
- 新聞中心
- 2024-11-13 14:17:08
- 41
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。
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。
下一篇:臺妹向前沖(向前沖現場版)