-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
44 lines (39 loc) · 1.07 KB
/
Copy pathPlayer.cpp
File metadata and controls
44 lines (39 loc) · 1.07 KB
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
// Class definition for XO_Player class
// Author: Mohammad El-Ramly
// Date: 10/10/2022
// Version: 1
#include<iostream>
#include<random>
#include<iomanip>
#include<algorithm>
#include"BoardGame_Classes.hpp"
using namespace std;
// Give player a symbol to use in playing
// It can be X or O or others
// This is needed for computer players
// as it does not ask for a name
Player::Player(char symbol) {
this->symbol = symbol;
}
// Optionally, you can give him ID or order
// Like Player 1 and Player 2
Player::Player (int order, char symbol) {
cout << "Welcome player " << order << endl;
cout << "Please enter your name: ";
cin >> name;
this->symbol = symbol;
}
// Get desired move: x y (each between 0 and 2)
// Virtual (can change for other player types)
void Player::get_move (int& x, int& y) {
cout << "\nPlease enter your move x and y (0 to 2) separated by spaces: ";
cin >> x >> y;
}
// Give player info as a string
string Player::to_string(){
return "Player: " + name ;
}
// Get symbol used by player
char Player::get_symbol() {
return symbol;
}