重慶分公司,新征程啟航
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)
class A{//類A計(jì)算立方體體積 }class B{//類A計(jì)算球體體積 } class C{//類A計(jì)算圓柱體積 }//主類public class test{ static{ System.out.println("請輸入1、2、3對應(yīng)立方體、球體和圓柱的體積計(jì)算..."); }public static void main(String args[]){ if(args.length1 || Integer.parseint(args[0])1|| Integer.parseint(args[0])3){//判斷輸入是否符合標(biāo)準(zhǔn) System.out.println("錯(cuò)誤的選擇,程序自動(dòng)退出.."); System.exit(1); } else{ int x = Integer.parseint(args[0]) ; switch(x){ case 1: //調(diào)用A類 case 2: //調(diào)用B類 defualt: //調(diào)用C類 } } }}
站在用戶的角度思考問題,與客戶深入溝通,找到商河網(wǎng)站設(shè)計(jì)與商河網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、空間域名、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋商河地區(qū)。
畫六個(gè)四邊形,組成立方體即可。(這個(gè)要用OpenGLES)
轉(zhuǎn)動(dòng)的話,用GestureLitener.
代碼如下
/**
*?Author:?zhyx
*?Date:2017/11/30
*?Time:8:56
*/
public?abstract?class?Contailner?{
double?r;
abstract?double?volume();
}
/**
*?Author:?zhyx
*?Date:2017/11/30
*?Time:8:57
*/
public?class?Cube?extends?Contailner?{
public?Cube(double?r)?{
this.r=r;
}
@Override
double?volume()?{
return?r*r*r;
}
}
/**
*?Author:?zhyx
*?Date:2017/11/30
*?Time:9:01
*/
public?class?Sphere?extends?Contailner?{
public?Sphere(double?r)?{
this.r=r;
}
@Override
double?volume()?{
return?4/3*Math.PI*r*r*r;
}
}
/**
*?Author:?zhyx
*?Date:2017/11/30
*?Time:9:02
*/
public?class?Tiji?{
public?static?void?main(String[]?args)?{
Cube?cube=new?Cube(4);
System.out.println("立方體體積為:"+cube.volume());
Sphere?sphere=?new?Sphere(4);
System.out.println("球體體積為:"+sphere.volume());
}
}
你的這個(gè)問題 是你定義類的問題,java雖然大小敏感,但是根據(jù)命名規(guī)范 一般類名首字母需要大寫,你2個(gè)類定義為同名,就是首字母大小寫不同,建議你改下。當(dāng)然文件名得跟public類名一樣
class Box{
private int x,y,z;
public void setDemo(){
x=3;
y=4;
z=5;
}
public void calculate(int x,int y,int z){
int t;
t=x*y*z;
System.out.println(t);
}
}
public class Test{
public static void main(String[] args) {
int t;
Box d=new Box();
d.setDemo();
d.calculate(3,4,5);
}
}