diff options
Diffstat (limited to 'labb8/lib/StanfordCPPLib/point.cpp')
| -rwxr-xr-x | labb8/lib/StanfordCPPLib/point.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/labb8/lib/StanfordCPPLib/point.cpp b/labb8/lib/StanfordCPPLib/point.cpp new file mode 100755 index 0000000..351e4c8 --- /dev/null +++ b/labb8/lib/StanfordCPPLib/point.cpp @@ -0,0 +1,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(); +} |
