Browse Source

refactoring: Using a loop

remotes/origin/Ariana
Ariana Ginju 11 months ago
committed by David Moeller
parent
commit
dff9fd6ec9
  1. 16
      src/main/c/GameTic_Tac_Toe/game.c

16
src/main/c/GameTic_Tac_Toe/game.c

@ -6,16 +6,22 @@ char board[3][3] = {{'1', '2', '3'},
char currentPlayer = 'X'; char currentPlayer = 'X';
const char PLAYER_X = 'X'; const char PLAYER_X = 'X';
const char PLAYER_O = 'O'; const char PLAYER_O = 'O';
// Funktionen zur Anzeige des Spielbretts // Funktionen zur Anzeige des Spielbretts
void displayBoard() { void displayBoard() {
printf("Tic-Tac-Toe\n"); printf("Tic-Tac-Toe\n");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
for (int i = 0; i < BOARD_SIZE; i++) {
for (int j = 0; j < BOARD_SIZE; j++) {
printf("%c", board[i][j]); printf("%c", board[i][j]);
if (j < 2) printf(" | ");
}
if (j < BOARD_SIZE - 1) printf(" | ");
}
printf("\n"); printf("\n");
if (i < 2) printf("---------\n");
if (i < BOARD_SIZE - 1) {
for (int k = 0; k < BOARD_SIZE * 4 - 1; k++) {
printf("-");
}
printf("\n");
}
} }
} }
char checkLine(char a, char b, char c) { char checkLine(char a, char b, char c) {

Loading…
Cancel
Save