C++ Project 2016-2017: Arkanoid
vector2D.cpp
Go to the documentation of this file.
1 
3 #include "vector2D.h"
4 
5 #include <iostream>
6 
7 using namespace std;
8 
9 namespace arkanoid {
10 
11  Vector2D::Vector2D() {};
12 
13  Vector2D::Vector2D(double newX, double newY) : x(newX), y(newY) {}
14 
15  Vector2D Vector2D::operator+(const Vector2D &other) const {
16  return Vector2D(x + other.x, y + other.y);
17  }
18 
19  void Vector2D::operator=(const Vector2D &other) {
20  x = other.x;
21  y = other.y;
22  }
23 
24  void Vector2D::operator+=(const Vector2D &other) {
25  x += other.x;
26  y += other.y;
27  }
28 
29  Vector2D Vector2D::operator*(double factor) const {
30  return Vector2D(x * factor, y * factor);
31  }
32 
33  void Vector2D::operator*=(double factor) {
34  x *= factor;
35  y *= factor;
36  }
37 
38  ostream& operator<<(ostream& stream, Vector2D& vector) {
39  stream << "(" << vector.x << ", " << vector.y << ")";
40  return stream;
41  }
42 
43 }
Vector2D operator+(const Vector2D &other) const
Definition: vector2D.cpp:15
void operator+=(const Vector2D &other)
Definition: vector2D.cpp:24
void operator=(const Vector2D &other)
Definition: vector2D.cpp:19
void operator*=(double factor)
Definition: vector2D.cpp:33
Representation of a vector.
Definition: vector2D.h:14
friend ostream & operator<<(ostream &stream, Vector2D &vector)
Definition: vector2D.cpp:38
double y
The &#39;y&#39; component of the Vector2D.
Definition: vector2D.h:18
double x
The &#39;x&#39; component of the Vector2D.
Definition: vector2D.h:17
All the game logic of the Arkanoid game.
Definition: ball.cpp:15
Vector2D operator*(double factor) const
Definition: vector2D.cpp:29