-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBoard.h
110 lines (90 loc) · 2.27 KB
/
Board.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
File Name: Board.h
Authors: Regan Janssen, Andrew Loaiza, Chen Lu, Jui Nagarkar, Natasha Shirley
Description: Board class creates grid and places the location of the ship. Allows players to view the board
Date: Sept. 19, 2021
*/
#ifndef BOARD_H
#define BOARD_H
#include <cstdlib>
#include <limits>
#include "Ship.h"
using namespace std;
class Board
{
private:
int numRows = 9; // Sets the number of rows for the board
int numCols = 10; // Sets the number of columns for the board
Ship m_grid[9][10]; // 2D array of type Ship
// char m_oppGrid[9][10]; // 2D array of char, this is what opponent will view
int m_row; //current row location
int m_col; //current col location
int m_numShips; //number of ships
int m_shipsSunk; //number of ships that have been sunk
string userInput; //string to store user input
bool validInput; //true if valid
string invalidCoordMessage; //stores error message
public:
/*
*Initializes a 9x10 board
*@param None
*@return none
*/
Board();
/*
*deallocates the board object
*@param None
*@return none
*/
~Board(); // avoid memory leaks!
/*
*Allows players to view their board as well as the opponents board with their hits and misses
*@param None
*@return none
*/
void viewBoard();
/*
*Allows players to view other player's board as well as the opponents board with their hits and misses
*@param None
*@return none
*/
void viewOBoard();
/*
*Ship is placed on the board
*@param number of ships
*@return none
*/
void shipPlacement(int numShips);
/*
*Converts string input to int, checks for out of bounds
*@param none
*@return none
*/
void convertCoord();
/*
*Checks if ship placement is valid
*@param int number for for loops and a bool for orientation
*@return none
*/
void checkValidShipPlacement(int shipSize, bool horizontal);
/*
*User chooses coordinates to shoot at
*@param None
*@returns none
*/
void fireAt();
bool isOnGrid(int row, int col);
/*
*Checks to see if the opponents ship sunk
*@param int for row and col location
*@return boolean value for ship status
*/
bool isSunk(int row, int col);
/*
*Checks to see if all ships have been sunk
*@param None
*@return boolean value for win status
*/
bool hasLost();
};
#endif