consolidate all repos to one for archive
This commit is contained in:
30
semester_2/programiranje_2/primeri/Example08/Point.cpp
Normal file
30
semester_2/programiranje_2/primeri/Example08/Point.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user