// File: Point.h
// Class Point interface
// Author: Eugene Smirnov
// Date: 1.04.06, Revision: 1.4

#ifndef POINT_H
#define POINT_H

#include "Shape.h"
#include "Hashable.h"
#include "utils.h"
#include <iostream>
using namespace std;


/**************************
 * Class represents point
 *************************/
class Point: virtual public Shape, virtual public Hashable{

  /*************************************
   *            private
   ************************************/
  private:

    // object 'id'
    const unsigned long int id;

    // 'x' coordinate
    double x;

    // 'y' coordinate
    double y;

    // radius
    double r;

    // angle
    double fi;

    /**
     * function that calculates point's angle
     * by it's 'x' and 'y' coordinates
     */
    void calculatePolarAngle();

    /**
     * function that converts (X,Y)
     * coordinates to (R,Fi)
     */
    void convertXYToRFi();

	void convertRFiToXY();

    /*************************************
     *         private static
     ************************************/

    // static variable used for storing
    // current number of objects
    static unsigned long int count;

    // static variable used for storing
    // total number of objects and for
    // creating unique object identifier
    static unsigned long int total;

  /*************************************
   *            public
   ************************************/
  public:

    /**
     * constructor
     * param x - 'x' coordinate
     * param y - 'y' coordinate
     * params initialize 'x' and 'y'
     * fields respectively
     */
    Point(const double x = 0, const double y = 0);

    /**
     * costructor
     * param point - pointer to Point object
     */
    Point(const Point* const point);


    /**
     * copy costructor
     * param point - Point object
     */
    Point(const Point& point);

    /**
     * destructor
     */
    virtual ~Point();

    /**
     * 'x' field accessor
     * return 'x' field value
     */
    double getX() const;

    /**
     * 'y' field accessor
     * return 'y' field value
     */  
    double getY() const;

    /**
     * 'r' field accessor
     * return 'r' field value
     */ 
    double getR() const; 

    /**
     * 'fi' field accessor
     * return 'fi' field value
     */ 
    double getFi() const;

    /**
     * move point
     * param 'dx' - dx
     * param 'dy' - dy
     */
    void moveBy(const double dx, const double dy);
 
    /**
     * turn point around (0,0)
     * param 'angle' - turn angle
     */
    void turnBy(const double angle);

    /**
     * turn point around other point
     * param 'angle' - turn angle
     * param 'point' - base point
     */
    void turnAroundBy(const double angle, const Point* const point);

    /** 
     * print object
     */
	ostream& print(ostream& os) const;

	string toString() const;

	Point& operator= (const Point& o);

	int operator==(const Point& o) const;

	/**
	 * object 'id' accessor
	 * return 'id' field value
	 */
	unsigned long int getObjectId() const{
		return id;
	}

	/**
	 * 'count' field accessor
	 * return 'count' field value
	 */
	static unsigned long int getNumberOfObjects(){ //const
		return count;
	}

	int hashCode() const{
		return buildHashCode(toString());
	}
};

#endif
Соседние файлы в папке lab1_1