12345678910111213141516171819202122232425262728293031 |
- #include "Vector.h"
- Vector::Vector(int x, int y) : x(x), y(y) {
- }
- void Vector::set(int x, int y) {
- this->x = x;
- this->y = y;
- }
- bool Vector::compare(int x, int y) const {
- return this->x == x && this->y == y;
- }
- Vector& Vector::operator+=(const Vector& other) {
- x += other.x;
- y += other.y;
- return *this;
- }
- Vector Vector::operator+(const Vector& other) const {
- return Vector(x + other.x, y + other.y);
- }
- Vector Vector::operator-(const Vector& other) const {
- return Vector(x - other.x, y - other.y);
- }
- bool Vector::operator==(const Vector& other) const {
- return compare(other.x, other.y);
- }
|