Professional Documents
Culture Documents
Proyecto Mina
Proyecto Mina
Random;
import java.util.Scanner;
// User input
Scanner scanner = new Scanner(System.in);
boolean foundTreasure = false;
int guessRows;
int guessColumns;
while (!foundTreasure) {
System.out.println("Enter the row and column of your guess (0-" +
(FILAS - 1) + "):");
guessRows = scanner.nextInt();
guessColumns = scanner.nextInt();
if (guessRows >= 0 && guessRows < FILAS && guessColumns >= 0 &&
guessColumns < COLUMNAS) {
if (board[guessRows][guessColumns] == TESORO) {
System.out.println("Congratulations! You found the treasure!");
foundTreasure = true;
} else {
System.out.println("Sorry, you didn't find the treasure. Try
again!");
board[guessRows][guessColumns] = INTENTO;
}
} else {
System.out.println("Invalid input. Please try again.");
}
}
scanner.close();