所以我必须创建一个宾果板,我已经这样做了,不要介意长码,它是第一列方法的重复。所以我想将这5个1D阵列转换成1个2D阵列,这样我就可以检查宾果游戏了。有人可以向我详细解释如何将这5个阵列转换为1个2D阵列,或者是否可以检查5个1D阵列。
package bingo;
import static java.rmi.Naming.list;
import java.util.ArrayList;
import java.util.Collections;
import static java.util.Collections.list;
import java.util.List;
public class Bingo {
public static void main(String[] args) {
int[][] card1 = new int[5][5];
int[] column1 = new int[5];
int[] column2 = new int[5];
int[] column3 = new int[5];
int[] column4 = new int[5];
int[] column5 = new int[5];
column1(column1);
System.out.println("");
column2(column2);
System.out.println("");
column3(column3);
System.out.println("");
column4(column4);
System.out.println("");
column5(column5);
System.out.println("");
cardofzeros(card1);
for (int i = 0; i < card1.length; i++) {
for (int j = 0; i < card1.length; i++) {
}
}
}
public static void column1(int[] column1) {
int[] colm = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
List l = new ArrayList();
for (int i : colm) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void column2(int[] column2) {
int[] colm2 = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
List l = new ArrayList();
for (int i : colm2) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void column3(int[] column3) {
int[] colm3 = {31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
List l = new ArrayList();
for (int i : colm3) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void column4(int[] column4) {
int[] colm4 = {46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60};
List l = new ArrayList();
for (int i : colm4) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void column5(int[] column5) {
int[] colm2 = {61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75};
List l = new ArrayList();
for (int i : colm2) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void cardofzeros(int[][] card1) {
for (int i = 0; i < 5; i++) {
for (int j = 0; i < 5; i++) {
card1[i][j]=0;
System.out.print("|"+card1[i][j]);
}
}
}
}
答案 0 :(得分:0)
int[] first = null;
int[] second = null;
int[] third = null;
int[] fourth = null;
int[] fifth = null;
int[][] arr2d = new int[][]{first , second , third , fourth , fifth};