-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.h
49 lines (37 loc) · 1.37 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
//
// Created by Ansore on 10-05-2015.
//
#ifndef BOARD_H_
#define BOARD_H_
#include <string>
#include <vector>
#include "Ship.h"
#include "Bomb.h"
class Board {
public:
Board();
Board(const std::string &filename); // loads board from file 'filename'
bool putShip(const Ship &ship, unsigned int index); // adds ship to the board, if possible
void moveShips(); // tries to randomly move all the ships of the fleet
bool attack(const Bomb &b);
std::vector<Ship> getShipList() const;
std::vector<std::vector<int>> getBoard();
Ship removeShip(size_t index);
void refreshBoard();
void display() const; // displays the colored board during the game
void show() const; // shows the attributes of the board (for debugging)
bool isValidPosition(const Ship ship);
unsigned int getShipPart(Ship ship, int line, int column) const;
friend std::ostream& operator<<(std::ostream& outputStream, const Board &board);
//getters
unsigned int getNumLines() const;
unsigned int getNumColumns() const;
private:
unsigned int numLines, numColumns;// redundant info
std::vector <Ship> ships; // ships that are placed on the board
std::vector <std::vector <int> > board; // each element indicates
// the index of a ship in the 'ships' vector
// (in the range 0..ships.size()-1) ;
// -1 is used to represent the sea
};
#endif //BOARD_H_