blob: 351e4c8890dde5f2b64f9714cda9cccc1c6a9e9d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*
* File: point.cpp
* ---------------
* This file implements the point.h interface.
*/
#include <string>
#include "point.h"
#include "strlib.h"
using namespace std;
Point::Point() {
x = 0;
y = 0;
}
Point::Point(int x, int y) {
this->x = x;
this->y = y;
}
int Point::getX() const {
return x;
}
int Point::getY() const {
return y;
}
string Point::toString() const {
return "(" + integerToString(x) + "," + integerToString(y) + ")";
}
bool Point::operator==(const Point & p2) const {
return (x == p2.x) && (y == p2.y);
}
bool Point::operator!=(const Point & p2) const {
return (x != p2.x) || (y != p2.y);
}
ostream & operator<<(ostream & os, const Point & pt) {
return os << pt.toString();
}
|