Wrzucę cały kod i poproszę o komentarze moich wypocin - jakieś wskazówki, na czym powinienem się skupić i co wam przyjdzie do głowy :) Jednej rzeczy tylko mi się jeszcze nie udało zrobić dlatego poproszę o jakąś podpowiedź jak mógłbym zapętlić tę grę (bez wklejania metod ponownie). Z góry dziękuje za jakiekolwiek komentarze.
int[][] easy = firstBoard();
System.out.println();
numberToGuess(easy);
nextLvl();
int[][] higher = nextBoard();
System.out.println();
numberToGuessNextLvl(higher);
nextLvl();
System.out.println();
nextBoard();
numberToGuessNextLvl(higher);
nextLvl();
}
public static int[][] firstBoard() {
Random rnd = new Random();
int[][] rndBoard = new int[5][5];
for (int x = 0; x < rndBoard.length; x++) {
for (int y = 0; y < rndBoard.length; y++) {
rndBoard[x][y] = rnd.nextInt(100) + 1;
rndBoard[2][2] = 0;
System.out.printf("%4d", rndBoard[x][y]);
}
System.out.println();
}
return rndBoard;
}
private static void numberToGuess(int[][] rndBoard) {
Random firstNumberToGuess = new Random();
final int x = firstNumberToGuess.nextInt(rndBoard.length);
final int y = firstNumberToGuess.nextInt(rndBoard[x].length);
final int value = rndBoard[x][y];
System.out.println("Zagramy w grę Shultz. Patrząc w środek tablicy " +
"gdzie jest zawsze liczba 0, dostrzeż okiem" + " " + value + " Nacisnij Y " +
"Jeżeli Ci się udało - przejdź na wyższy lvl");
}
public static void nextLvl() {
Scanner sc = new Scanner(System.in);
String decide = sc.nextLine();
String goNextLvl = String.valueOf('y');
String resigantion = String.valueOf('n');
if (decide.equals(goNextLvl)) {
System.out.println("Udało Ci śię! Jak duża ma być nowa tablica? Pamiętaj aby wybrać liczbę nieparzystą");
} else if (decide.equals(resigantion)) {
System.out.println("Dzięki za grę");
System.exit(0);
} else {
System.out.println("Are you retard?");
System.exit(1);
}
}
public static int[][] nextBoard() {
Random rnd = new Random();
Scanner sc = new Scanner(System.in);
int howBig = sc.nextInt();
int[][] rndNextBoard = new int[howBig][howBig];
for (int x = 0; x < rndNextBoard.length; x++) {
for (int y = 0; y < rndNextBoard.length; y++) {
rndNextBoard[x][y] = rnd.nextInt(100) + 1;
rndNextBoard[howBig / 2][howBig / 2] = 0;
System.out.printf("%4d", rndNextBoard[x][y]);
}
System.out.println();
}
return rndNextBoard;
}
private static void numberToGuessNextLvl(int[][] rndNextBoard) {
Random nextNumberToGuess = new Random();
final int x = nextNumberToGuess.nextInt(rndNextBoard.length);
final int y = nextNumberToGuess.nextInt(rndNextBoard[x].length);
final int value = rndNextBoard[x][y];
System.out.println( " Jeżli zauważyłeś liczbę: " + value + " i chcesz grać dalej naciśnij y, jeżeli chcesz przerwać naciśnij n");
}
}