From 3cd4c0eb292b44b4a9695c70f3336b896287d46e Mon Sep 17 00:00:00 2001 From: Sabina Grisi Date: Fri, 9 Feb 2024 20:36:08 +0100 Subject: [PATCH] refactoring neue Funktion int switchPlayer(int player) --- src/TicTacToe.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/TicTacToe.c b/src/TicTacToe.c index e28e1be..3c7d1d1 100644 --- a/src/TicTacToe.c +++ b/src/TicTacToe.c @@ -48,7 +48,7 @@ int main() { } drawBoard(pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9); - player = (player == 10) ? 11 : 10; + player = switchPlayer(player); } return 0; } @@ -136,4 +136,12 @@ void drawBoard(int pos1, int pos2, int pos3, int pos4, int pos5, int pos6, int p } printf("%c\n", vertical); printf("%c%s%c%s%c%s%c\n", vertical, horizontal, vertical, horizontal, vertical, horizontal, vertical); +} + +int switchPlayer(int player) { + if (player == 10) { + return 11; + } else { + return 10; + } } \ No newline at end of file