-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameManager1.cpp
More file actions
46 lines (36 loc) · 1005 Bytes
/
Copy pathGameManager1.cpp
File metadata and controls
46 lines (36 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// Created by DELL on 12/17/2023.
//
#include "Game1.h"
// Class definition for XO_GameManager class
// Author: Mohammad El-Ramly
// Date: 10/10/2022
// Version: 1
#include <iostream>
using namespace std;
GameManager1::GameManager1(Board1* bPtr, Player1* playerPtr[2] ) {
boardPtr = bPtr;
players[0] = playerPtr[0];
players[1] = playerPtr[1];
}
void GameManager1::run() {
int x, y;
boardPtr->display_board1();
while (!boardPtr->game_is_over1()) {
for (int i:{0,1}) {
players[i]->get_move(x, y);
while (!boardPtr->update_board1 (x, y, players[i]->get_symbol())){
players[i]->get_move(x, y);
}
boardPtr->display_board1();
if (boardPtr->is_winner1()){
cout << players[i]->to_string() << " wins\n";
return;
}
if (boardPtr->is_draw1()){
cout << "Draw!\n";
return;
}
}
}
}