-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint.h
42 lines (33 loc) · 976 Bytes
/
Point.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
//
// Point.h
// BATTLESHIP
//
#pragma once
#include <iostream>
using namespace std;
#define BOARD_LENGTH 10
#define BOARD_WIDTH 10
// Structure definition for Point struct
// Corresponds to a row number and column number
struct Point
{
// A location on the grid defined
// by X(horizontal) Y(vertical) coordinates
int X;
int Y;
// Equivalence operator defined for Point types
bool operator == (const Point& compareTo) const
{
return ( (X == compareTo.X) && (Y == compareTo.Y) );
}
};
// Output operator defined for Point types
// Outputs point in traditional format (row#, column#)
inline ostream& operator <<(ostream& out, Point myPoint)
{
// Increment X and Y coordinate to account for indexing
myPoint.X++; myPoint.Y++;
// Prints the coordinate to the console is traditional form (X,Y)
out << "(" << myPoint.X << "," << myPoint.Y << ")";
return out;
}