#include <iostream>
#include "point.h"
#include "math.h"

using namespace std;

Point::Point (int a, int b)
    :  x(a),  y(b)
{
}

double distance2 (const Point & a, const Point & b)
{
    int tmp_x;
    int tmp_y;

    double dist;

    tmp_x = a.x - b.x;
    tmp_y = a.y - b.y;

    tmp_x = tmp_x * tmp_x;
    tmp_y = tmp_y * tmp_y;

    dist = tmp_x + tmp_y;

    dist = sqrt(dist);

    return dist;
}

double Point::distance1 (const Point & b)
{
    int tmp_x;
    int tmp_y;

    double dist;

    tmp_x = this->x - b.x;
    tmp_y = this->y - b.y;

    tmp_x = tmp_x * tmp_x;
    tmp_y = tmp_y * tmp_y;

    dist = tmp_x + tmp_y;

    dist = sqrt(dist);

    return dist;
}

Point operator+ (const Point & p1, const Point & p)
{
    return Point(p1.x+p.x, p1.y+p.y);
}

Point operator+ (const int p, const Point & p1)
{
    return Point(p1.x+p, p1.y);
}

Point operator+ (const Point & p1, const int p)
{
    return Point(p1.x+p, p1.y);
}

Point & Point::operator+= (const Point & p1)
{
    x += p1.x;
    y += p1.y;

    return *this;
}

ostream & operator<< (ostream & os, const Point & p)
{
    os << '(' << p.x << ',' << p.y << ')';
    return os;
}
