From ed7690a49b00bc1406ace8ea492b6c71958caf81 Mon Sep 17 00:00:00 2001 From: Aimee Reincke Date: Thu, 2 Feb 2023 18:36:44 +0100 Subject: [PATCH] added print winner function --- src/c/ticTacToe.c | 14 +++++++++++++- src/c/ticTacToe.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/c/ticTacToe.c b/src/c/ticTacToe.c index 915e796..610a8ec 100644 --- a/src/c/ticTacToe.c +++ b/src/c/ticTacToe.c @@ -886,6 +886,18 @@ int play() { counter += 1; } printField(field); - printf("%d", winner); + printWinner(winner); return winner; +} + +void printWinner(int winner){ + if(winner == PLAYER){ + printf("You won\n"); + } + else if(winner == COMPUTER){ + printf("I won\n"); + } + else if(winner == DRAW){ + printf("It's a draw\n"); + } } \ No newline at end of file diff --git a/src/c/ticTacToe.h b/src/c/ticTacToe.h index 007b9cb..7033e57 100644 --- a/src/c/ticTacToe.h +++ b/src/c/ticTacToe.h @@ -18,5 +18,6 @@ int wasGameWon(char field[3][3]); void getComputerInput(char field[3][3]); void fillAlmostFull(char field[3][3], bool *pt); int play(); +void printWinner(int winner); #endif \ No newline at end of file