31 lines
531 B
C++
31 lines
531 B
C++
#include <iostream>
|
|
#include <cmath>
|
|
#include "Point.h"
|
|
|
|
Point::Point() : x(0), y(0) {
|
|
}
|
|
|
|
Point::Point (int x, int y) : x(x), y(y) {
|
|
}
|
|
|
|
Point::~Point() {
|
|
//std::cout << "destructor Point" << std::endl;
|
|
}
|
|
|
|
int Point::getX() const {
|
|
return x;
|
|
}
|
|
|
|
int Point::getY() const {
|
|
return y;
|
|
}
|
|
|
|
void Point::print() const {
|
|
std::cout << "(" << x << ", " << y << ") " << std::endl;
|
|
}
|
|
|
|
double Point::distance(const Point& p) const {
|
|
return std::sqrt((double)(x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
|
|
}
|
|
|