Point.h

/*

Programmer: Jennifer Leopold

Date: November 10, 2016

File: point.h

Purpose: This file contains the definition of a Point class.

*/

#ifndef POINT_H

#define POINT_H

#include <iostream>

#include <cstdlib>

using namespace std;

// Constants for possible change in direction

const int NUM_DIRECTIONS = 4;

const int UP = 0;

const int DOWN = 1;

const int LEFT = 2;

const int RIGHT = 3;

class Point

{

private:

// Member variables for x and y coordinates

int m_x, m_y;

public:

// Default constructor for Point.

// Preconditions: None

// Postconditions: m_x set to 0 and m_y set to 0.

Point(): m_x(0), m_y(0) { }

// Parameterized constructor for Point

// Preconditions: x has a value, y has a value

// Postconditions: m_x set to x and m_y set to y.

Point(const int x, const int y) : m_x(x), m_y(y) { }

// Accessor for m_x.

// Preconditions: None

// Postconditions: Value of m_x is returned.

int getX() const { return m_x; }

// Accessor for m_y.

// Preconditions: None

// Postconditions: Value of m_y is returned.

int getY() const { return m_y; }

// Overloaded = operator.

// Preconditions: p should have values for m_x and m_y.

// Postconditions: This Point's m_x and m_y have been set

// to the values of p's m_x and m_y, respectively. This

// Point is returned.

Point& operator =(const Point &p);

// Overloaded operator for <<.

// Preconditions: None

// Postconditions: Point's member var values will be

// output to outs, thereby modifying ostream outs, and

// outs is returned.

friend ostream& operator <<(ostream& out, const Point& p);

// Create a point with same coordinates as this point,

// but offset by 1 in a randomly chosen direction.

// Preconditions: None

// Postconditions: Returns a point that has same

// coordinates as this point, but offset by 1 in a

// randomly chosen direction.

Point getRandomNeighbor() const;

};

#endif