-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClasses.h
More file actions
132 lines (124 loc) · 3.25 KB
/
Classes.h
File metadata and controls
132 lines (124 loc) · 3.25 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef CLASSES_H
#define CLASSES_H
#include <string>
#include <vector>
using namespace std;
class WaterVehicle
{
private:
string name;
int lengthOfShip;
char xCord;
int yCord;
char horiOrVert;
bool sunk;
bool ready = false; //default is false and will be changed when succefully added to true
int damageTaken;
public:
WaterVehicle() { ; }
void setNameOfShip(string _name) { name = _name; }
string getNameOfShip() { return name; }
void setLengthOfShip(int _lengthOfShip) { lengthOfShip = _lengthOfShip; }
int getLengthOfShip() { return lengthOfShip; }
void setLocationX(char _location) { xCord = _location; }
char getLocationX() { return xCord; }
void setLocationY(int _location) { yCord = _location; }
int getLocationY() { return yCord; }
void setHorzOrVert(char _horiOrVert) { horiOrVert = _horiOrVert; }
char getHorzOrVert() { return horiOrVert; }
void setSunk(bool _sunk) { sunk = _sunk; }
bool getSunk() { return sunk; }
void setReady(bool _ready) { ready = _ready; }
bool getReady() { return ready; }
void setDamageTaken(int _damageTaken) { damageTaken = _damageTaken; }
int getDamageTaken() { return damageTaken; }
void increaseDamageTaken() { damageTaken++; }
friend ostream &operator << (ostream &out, WaterVehicle _object);
};
class Grid
{
private:
WaterVehicle Carrier;
WaterVehicle Battleship;
WaterVehicle Cruiser;
WaterVehicle Submarine;
WaterVehicle Destroyer;
vector<vector<char> > grid;
public:
Grid();
void initializeShip(string nameOfShip, char xCordTemp, int yCordTemp, char HoriOrVertTemp);
void setShip(WaterVehicle &object, char xCordTemp, int yCordTemp, char HoriOrVertTemp);
void printGrid();
void printBoats();
void setGrid(int locationX, int locationY, char value);
bool getReadyStatus();
int getGridPosition(int xCord, int yCord);
bool isGameOver();
bool isHit(int xCord, int yCord);
};
//each player has a grid
//each grid has a watervehicle
//a user is a player
//a bot is a player
//a game has players who have grids
class Player
{
protected:
// char xTorp;
// int yTorp;
// char xStart;
// int yStart;
Grid playerGrid;
public:
Player() { ; }
void createCordShips() { ; }
void isReady() { ; }
void showGrid() { ; }
void updateGrid() { ; }
int getGridPosition(int xCord, int yCord) { ; }
int createTorpX() { ; }
int createTorpY() { ; }
void setSinkStatus(int xCord, int yCord) { ; }
bool isGameOver() { ; }
};
class User : public Player
{
public:
User() { ; }
void createCordShips();
void isReady(User player1);
void showGrid();
bool updateGrid(int xCord, int yCord);
int getGridPosition(int xCord, int yCord);
int createTorpX();
int createTorpY();
void setSinkStatus(int xCord, int yCord);
bool isGameOver();
};
class Bot : public Player
{
private:
vector<vector<char> > botGrid; //FAKE GRID
public:
Bot();
void createCordShips();
void isReady(Bot player2);
void showGrid();
void showGridCheat();
bool updateGrid(int xCord, int yCord);
int getGridPosition(int xCord, int yCord);
int createTorpX();
int createTorpY();
void setSinkStatus(int xCord, int yCord);
bool isGameOver();
};
class Game
{
private:
User player1;
Bot player2;
public:
Game();
void playGame();
};
#endif