Untitled
unknown
plain_text
a year ago
1.8 kB
7
Indexable
#include "point.h" #include <iostream> #include <math.h> using namespace std; Point::Point(int x, int y) : x(x), y(y) { } Point::~Point() { cout << "Destroying Point: " << *this << endl; } Point::Point(const Point &src) { this->x = src.x; this->y = src.y; } int Point::getX(void) { return this->x; } void Point::setX(int x) { this->x = x; } int Point::getY(void) { return this->y; } void Point::setY(int y) { this->y = y; } Point Point::operator+(Point &rhs) { Point pt(this->x + rhs.x, this->y + rhs.y); return pt; } Point Point::operator+(int rhs) { Point pt(this->x + rhs, this->y + rhs); return pt; } Point operator+(int lhs, Point &rhs) { Point pt(lhs + rhs.x, lhs + rhs.y); return pt; } bool Point::operator>(int rhs) { if (this->x > rhs || (this->x == rhs && this->y > rhs)) return true; return false; } bool Point::operator>(Point &rhs) { if (this->x > rhs.x || (this->x == rhs.x && this->y > rhs.y)) return true; return false; } Point Point::operator=(Point& rhs) { this->x = rhs.x; this->y = rhs.y; return *this; } Point Point::operator++(void) { this->x++; this->y++; return *this; } Point Point::operator++(int) { Point pt(this->x, this->y); this->x++; this->y++; return pt; } ostream &operator<<(ostream &os, Point &rhs) { os << "{x: " << rhs.x << ", y: " << rhs.y << " }"; return os; } void Point::Move(int x, int y) { this->x += x; this->y += y; } void Point::MoveX(int x) { this->x += x; } void Point::MoveY(int y) { this->y += y; } void Point::Rotate(int angle) { this->x = sin(angle); this->y = sin(angle); } void Point::Rotate3D(int x, int y, int z) { this->x = cos(x); this->y = cos(x); }
Editor is loading...
Leave a Comment