Last active
March 5, 2019 21:30
-
-
Save Ben1980/93d2854642f074929f21433aa86b990f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size_t Particle::IDCounter = 0; | |
Particle::Particle() | |
: mass(0) { | |
id = IDCounter++; | |
} | |
Particle::Particle(double mass, const Vector2D &acceleration, const Vector2D &velocity, const Vector2D &position) | |
: mass(mass), acceleration(acceleration), velocity(velocity), position(position) { | |
assert(mass > 0); | |
id = IDCounter++; | |
} | |
bool Particle::operator==(const Particle &rhs) const { | |
return id == rhs.id; | |
} | |
bool Particle::operator!=(const Particle &rhs) const { | |
return !(rhs == *this); | |
} | |
const Vector2D &Particle::getAcceleration() const { | |
return acceleration; | |
} | |
void Particle::setAcceleration(const Vector2D &acceleration) { | |
Particle::acceleration = acceleration; | |
} | |
const Vector2D &Particle::getVelocity() const { | |
return velocity; | |
} | |
void Particle::setVelocity(const Vector2D &velocity) { | |
Particle::velocity = velocity; | |
} | |
const Vector2D &Particle::getPosition() const { | |
return position; | |
} | |
void Particle::setPosition(const Vector2D &position) { | |
Particle::position = position; | |
} | |
double Particle::getMass() const { | |
return mass; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment