Updated the tictactoe.cpp

This commit is contained in:
Mathias Wagner 2023-09-27 20:51:18 +02:00
parent 71e5a6cb32
commit 5ab0e2ce8c
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -7,10 +7,7 @@ using namespace std;
class TikTakToe { class TikTakToe {
public: public:
string rows[9] = { string rows[9] = {"-", "-", "-","-", "-", "-","-", "-", "-"};
"-", "-", "-",
"-", "-", "-",
"-", "-", "-"};
public: public:
bool playerWon(string character) { bool playerWon(string character) {
@ -53,13 +50,14 @@ public:
cout << rows[i] + " "; cout << rows[i] + " ";
} }
cout << "\n=====\nWo soll dein X hin? [1-9] ";
} }
public: public:
void awaitInput() { void awaitInput() {
printBoard(); printBoard();
cout << "\n=====\nWo soll dein X hin? [1-9] ";
int input; int input;
cin >> input; cin >> input;
@ -80,16 +78,20 @@ int main() {
board.awaitInput(); board.awaitInput();
} }
cout << "\n===== ENDSTAND ====="; cout << "\n===== ENDSTAND ";
board.printBoard(); board.printBoard();
cout << "\n===== ENDSTAND =====";
if (board.playerWon("X")) { if (board.playerWon("X")) {
cout << "\n\nDu hast gewonnen! Herzlichen Glückwunsch. :)"; cout << "\n\nDu hast gewonnen! Herzlichen Glückwunsch. :)";
} else { } else {
cout << "Du hast legit gegen einen random Bot verloren, würd mir mal Gedanken machen.."; cout << "Du hast legit gegen einen random Bot verloren, würd mir mal Gedanken machen..";
} }
cout << "\n\n";
return 0; return 0;