/**************************************************************************
 * Course Project Header File: Point.h                                    *
 *                                                                        *
 * Description: This class defines a two-dimensional point.               *
 *                                                                        *
 **************************************************************************/
#ifndef _POINT_H
#define _POINT_H

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream.h>

class Point
{
public:
  /**
   * Default constructor.
   *     To construct a 2-D point with the given x and y coordinates.
   *
   * parameter x: x coordinate of the constructed point.
   * parameter y: y coordinate of the constructed point.
   */
  Point (int x = 0, int y = 0);

  /**
   * Copy constructor.
   *     To construct a 2-D point with the same x and y coordinates of
   *     a given point.
   *
   * parameter point: a 2-D point.
   */
  Point (const Point& point);

  /**
   * Assignment operator.
   *     To assign the x and y coordinates of an existing 2-D point to
   *     those of another point.
   *
   * parameter point: a 2-D point.
   */
  Point& operator = (const Point& point);

  
  /**
   * Destructor.
   *     To release all resources associated with this 2-D point.
   */
  ~Point (void);

  /**
   * Calculate the distance between this point and another point.
   *
   * parameter point: a 2-D point.
   * return: distance between this and point.
   */
  double distance (const Point& point) const;

  
  /**
   * Return the x coordinate of this point.
   *
   * return: the x coordinate of this point.
   */
  int  x (void) const;

  /**
   * Return the y coordinate of this point.
   *
   * return: the y coordinate of this point.
   */
  int  y (void) const;

  /**
   * Set  the x and y coordinates of this point.
   *
   */
  void set (int x, int y);

  /**
   * Comparison operator.
   *     Check whether point0 and point1 are the same.
   *
   * return: 1 if point0 and point1 are the same.
   *         0 if point0 and point1 are not the same.
   */
  friend int operator == (const Point& point0, const Point& point1);

  /**
   * Comparison operator.
   *     Check whether point0 and point1 are different.
   *
   * return: 1 if point0 and point1 are different.
   *         0 if point0 and point1 are the same.
   */
  friend int operator != (const Point& point0, const Point& point1);

  /**
   * Overloaded output stream operator.
   *     This operator enables the following statements:
   *     Point p(2, 4);
   *     cout << p;
   *
   *     The format of an output stream is: 
   *     23 71
   */
  friend ostream& operator << (ostream& os, const Point& p)
    {return os << p.x_ << " " << p.y_;}  

  /**
   * Overloaded input stream operator.
   *     This operator enables the following statements:
   *     Point p;
   *     cin >> p;
   *
   *     The format of an input stream is:
   *     8 25
   */
  friend istream& operator >> (istream& is, Point& p)
    {return is >> p.x_ >> p.y_;}

private:
  // internal x and y coordinates of this point.
  int x_;
  int y_;
};
#endif

