Browse Source

added print winner function

remotes/origin/ticTacToe
Aimee Reincke 2 years ago
parent
commit
ed7690a49b
  1. 14
      src/c/ticTacToe.c
  2. 1
      src/c/ticTacToe.h

14
src/c/ticTacToe.c

@ -886,6 +886,18 @@ int play() {
counter += 1; counter += 1;
} }
printField(field); printField(field);
printf("%d", winner);
printWinner(winner);
return 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");
}
} }

1
src/c/ticTacToe.h

@ -18,5 +18,6 @@ int wasGameWon(char field[3][3]);
void getComputerInput(char field[3][3]); void getComputerInput(char field[3][3]);
void fillAlmostFull(char field[3][3], bool *pt); void fillAlmostFull(char field[3][3], bool *pt);
int play(); int play();
void printWinner(int winner);
#endif #endif
Loading…
Cancel
Save