-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShip.h
73 lines (49 loc) · 1.82 KB
/
Ship.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
// Ship.h - Ship class declaration
// Written by Michael Onjack
#pragma once
#include <string>
#include "Point.h"
#include "Board.h"
using namespace std;
#define SHIP_TYPES 5
#define MAX_LENGTH 5
enum DIRECTION {HORIZONTAL,VERTICAL};
class Ship
{
public:
// Constructor
Ship();
// Function to initially set all ship to the correct values
void LoadShips( Ship ship[SHIP_TYPES] );
// Function which gives ships their location points and placement orientation
void FillShipData( const DIRECTION& direction, Point coordinate );
// Returns true if the ship has been sunk
bool isSunk( const Board& opponentBoard ) const;
// Returns true if the ship has been hit by opponent's strike
bool isHit( const Point& guess, Ship ship[SHIP_TYPES] ) const;
// Returns true if the player is allowed to place their ship on the requested coordinate
bool CheckPlacement( Point placePoint, const DIRECTION& direction, const Ship ship[], const Ship& currentShip, int shipNumber);
// Prints the ratio of how many times the ship has been hit relative to its size
void PrintDamage() const;
// Getter function for the name of the ship
string GetName() const
{ return Name; }
// Getter function for the length of the ship
int GetLength() const
{ return Length; }
int GetHits() const
{ return Hits; }
const Point* GetSpaceOccupied() const
{ return spaceOccupied; }
private:
// Ship name
string Name;
// How many spaces the ship occupies
int Length;
// How many hits the ship has suffered
int Hits;
// Determines whether a ship lies vertically or horizontally on the board
DIRECTION Direction;
// Holds the coordinates that the ship occupies
Point spaceOccupied[MAX_LENGTH];
};