forked from MarkusBecerra/BattleShip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
57 lines (48 loc) · 1.04 KB
/
Player.cpp
File metadata and controls
57 lines (48 loc) · 1.04 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
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* \Author: Chance Penner
* \Author: Markus Becerra
* \Author: Sarah Scott
* \Author: Thomas Gardner
* \Author: Haonan Hu
* \File: Player.cpp
* \Date: 09/19/2019
* \Brief: File is cpp file
* \copyright: Group "Big SegFault Energy" All rights reserved
*/
#include "Player.h"
Player::Player(int shipNums)
{
m_board = new Board(shipNums);
numOfShips = shipNums;
}
Player::~Player()
{
delete m_board;
}
void Player::setRecentGuess(std::string userGuess)
{
recentguess = userGuess;
}
std::string Player::getRecentGuess() const
{
return recentguess;
}
void Player::shooting(std::string userGuess, bool hit)
{
m_board->updateShotBoard(userGuess, hit); //update the shot board after player shooting
}
bool Player::gettingShot(std::string userGuess)
{
if(m_board->withinBoundary(userGuess)) // check userGuess within boundary or not
{
return (m_board->updateMyBoard(userGuess)); //updated player's board after get shot
}
else
{
throw(std::runtime_error("Out of Boundary! Try again.\n"));
}
}
Board* Player::getBoard() const
{
return m_board;
}