public static String[] getWords(int cat, int diff) {
String topic[][][] = new String[3][3][3];
switch(cat){
case 0:
topic[0][0][0] = "Paris";
topic[0][0][1] = "London";
topic[0][0][2] = "Sydney";
diff = 0;
topic[0][1][0] = "Toronto";
topic[0][1][1] = "Florida";
topic[0][1][2] = "Frankfurt";
diff = 1;
topic[0][2][0] = "Barcelona";
topic[0][2][1] = "Vancouver";
topic[0][2][2] = "Zimbabwe";
diff = 2;
case 1:
topic[1][0][0] = "Halo";
topic[1][0][1] = "Fifa";
topic[1][0][2] = "GTA";
diff = 0;
topic[1][1][0] = "Skyrim";
topic[1][1][1] = "HITMAN";
topic[1][1][2] = "Batman";
diff =1;
topic[1][2][0] = "Minecraft";
topic[1][2][1] = "Zombieville";
topic[1][2][2] = "BoderLands";
diff =2;
case 2:
topic[2][0][0] = "Acura";
topic[2][0][1] = "Audi";
topic[2][0][2] = "Bmw";
diff = 0;
topic[2][1][0] = "Bentley";
topic[2][1][1] = "Buggati";
topic[2][1][2] = "Honda";
diff = 1;
topic[2][2][0] = "Lamborghini";
topic[2][2][1] = "Rolls-Royce";
topic[2][2][2] = "Mercedes";
diff = 2;
}
return topic[cat][diff];
}
所以這我的方法與3D陣列,我想知道如果我這樣做是正確的,並且如果我在main方法中調用它能否行得通?我用開關語句,因爲有人推薦我,我真的是新的Java,因爲你可以看到 這是遊戲Hang子手3D陣列不工作
您是否注意到您在每個案例結束時沒有「break」聲明?這是不太可能被期望的。我們無法確定它是否可行,因爲我們不知道它正在努力達成什麼 - 但它不可能是實現這一目標的最佳方式,IMO。 –
在主要方法中,將詢問他們想要玩什麼類別和難度級別以及他們選擇的任何內容將讀入該方法並轉到該部分,您如何做到這一點 –