Here is how the entire thing looks like now.
And then there is the details that you're forced to add and more details and more details and more details and more and more and more and more and more and more and more and more and more and more and more
import java.util.Scanner;
public class Tictactoe {
static char[][] MakeMove(char[][] spelplan, char spelare, int rad, int kolumn) {
spelplan[rad][kolumn] = spelare;
char[][] board = new char[4][4];
System.out.println(spelplan[rad][kolumn]);
return spelplan;
}
static boolean CheckMove(char[][] spelplan, int x, int y) {
if (spelplan[x][y] != ' ') {
return false;
} else {
return true;
}
}
static void SkrivUtSpelplan(char[][] spelplan) {
System.out.println("-------");
System.out.println("|" + spelplan[1][1] + "|" + spelplan[1][2] + "|" + spelplan[1][3] + "|");
System.out.println("|-+-+-|");
System.out.println("|" + spelplan[2][1] + "|" + spelplan[2][2] + "|" + spelplan[2][3] + "|");
System.out.println("|-+-+-|");
System.out.println("|" + spelplan[3][1] + "|" + spelplan[3][2] + "|" + spelplan[3][3] + "|");
System.out.println("-------");
}
static boolean KollaVinst(char[][] spelplan) {
return false;
}
public static void main(String[] args) {
char spelplan[][] = new char[4][4];
char spelare;
int rad = 3, kolumn = 3, i = 0;
for (int x = 1; x < 4; x++) {
for (int y = 1; y < 4; y++) {
spelplan[x][y] = ' ';
}
}
System.out.println("-------");
System.out.println("| | | |");
System.out.println("|-+-+-|");
System.out.println("| | | |");
System.out.println("|-+-+-|");
System.out.println("| | | |");
System.out.println("-------");
while (KollaVinst(spelplan) == false) {
CheckMove(spelplan, rad, kolumn);
for (i = 0; i < 9; i++) {
if (i % 2 == 0) {
spelare = 'X';
} else {
spelare = 'O';
}
System.out.println("Spelare 1 skriv vilken rad: 1-3");
int x = new Scanner(System.in).nextInt();
System.out.println("Spelare 1 skriv vilken kolumn: 1-3");
int y = new Scanner(System.in).nextInt();
if (CheckMove(spelplan, x, y) == true) {
MakeMove(spelplan, spelare, x, y);
}
System.out.println(" ");
SkrivUtSpelplan(spelplan);
}
}
}
}