ese 519
Diff: location.cpp
- Revision:
- 0:2076b4d80327
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/location.cpp Tue Apr 07 21:09:22 2015 +0000 @@ -0,0 +1,54 @@ +#include "../include/location.h" +#include <iostream> + +Location& Location::operator= (const Location& rhs) +{ + x = (rhs.x); + y = (rhs.y); + z = (rhs.z); + return *this; +} + +Location& Location::operator+= (const Location& rhs) +{ + x = x + rhs.x; + y = y + rhs.y; + z = z + rhs.z; + return *this; +} + +Location operator+ (Location lhs, const Location& rhs) +{ + lhs += rhs; + return lhs; +} + +bool Location::operator< (const Location& rhs) const +{ + if (x == rhs.x){ + if (y == rhs.y){ + return z < rhs.z; + }return y < rhs.y; + }return x < rhs.x; +} + +ostream& operator<< (ostream& os, Location obj) +{ + os << obj.getX() <<","<< obj.getY() <<","<< obj.getZ(); + return os; +} + +float Location::getX (void) const +{ + return this->x; +} + +float Location::getY (void) const +{ + return this->y; +} + +float Location::getZ (void) const +{ + return this->z; +}