Generation

generate functionSun, 16 Jul 2023

Se colocan una mina y un tesoro de forma aleatoria en un cuadrante de cinco filas por cinco columnas. El usuario intentará averiguar dónde está el tesoro indicando la fila y columna que donde cree que está el tesoro.

char [][] tablero = new char [5][5]; int [] posicionMina = new int [2]; int [] posicionTesoro = new int [2]; int [] posicionJugador = new int [2]; int [] tableroJugador = new int [2]; int [] tableroJugador = new int [2]; public void inicializarTablero(){ for(int i = 0; i < tablero.length; i++){ for(int j = 0; j < tablero.length; j++){ tablero[i][j] = '0'; } } } public void posicionMinaYTesoro(){ Random r = new Random(); posicionMina[0] = r.nextInt(tablero.length); posicionMina[1] = r.nextInt(tablero.length); do{ posicionTesoro[0] = r.nextInt(tablero.length);

Questions about programming?Chat with your personal AI assistant