-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Ben1980/develop
Develop
- Loading branch information
Showing
8 changed files
with
101 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
#ifndef PARTICLE_H | ||
#define PARTICLE_H | ||
|
||
#include "types.h" | ||
|
||
struct Particle { | ||
double mass; | ||
Vector2D acceleration; | ||
Vector2D velocity; | ||
Vector2D position; | ||
|
||
Particle() : mass(0) {} | ||
Particle(double mass, const Vector2D &acceleration, const Vector2D &velocity, const Vector2D &position) | ||
: mass(mass), acceleration(acceleration), velocity(velocity), position(position) {} | ||
}; | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
#ifndef PARTICLEBUILDER_H | ||
#define PARTICLEBUILDER_H | ||
|
||
#include "types.h" | ||
|
||
class Particle; | ||
|
||
class ParticleBuilder { | ||
public: | ||
ParticleBuilder * position(); | ||
ParticleBuilder * velocity(); | ||
ParticleBuilder * acceleration(); | ||
ParticleBuilder * mass(); | ||
Particle build(); | ||
ParticleBuilder() : mMass(0) {} | ||
|
||
ParticleBuilder & position(const Vector2D &position); | ||
ParticleBuilder & velocity(const Vector2D &velocity); | ||
ParticleBuilder & acceleration(const Vector2D &acceleration); | ||
ParticleBuilder & mass(double mass); | ||
Particle build() const; | ||
|
||
private: | ||
double mMass; | ||
Vector2D mAcceleration; | ||
Vector2D mVelocity; | ||
Vector2D mPosition; | ||
}; | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef TYPES_H | ||
#define TYPES_H | ||
|
||
struct Vector2D { | ||
double x; | ||
double y; | ||
|
||
Vector2D() : x(0), y(0) {} | ||
Vector2D(double x, double y) : x(x), y(y) {} | ||
}; | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
#include "particleBuilder.h" | ||
#include "particle.h" | ||
|
||
ParticleBuilder * ParticleBuilder::position() | ||
ParticleBuilder & ParticleBuilder::position(const Vector2D &position) | ||
{ | ||
return this; | ||
mPosition = position; | ||
return *this; | ||
} | ||
|
||
ParticleBuilder * ParticleBuilder::velocity() | ||
ParticleBuilder & ParticleBuilder::velocity(const Vector2D &velocity) | ||
{ | ||
return this; | ||
mVelocity = velocity; | ||
return *this; | ||
} | ||
|
||
ParticleBuilder * ParticleBuilder::acceleration() | ||
ParticleBuilder & ParticleBuilder::acceleration(const Vector2D &acceleration) | ||
{ | ||
return this; | ||
mAcceleration = acceleration; | ||
return *this; | ||
} | ||
|
||
ParticleBuilder * ParticleBuilder::mass() | ||
ParticleBuilder & ParticleBuilder::mass(double mass) | ||
{ | ||
return this; | ||
mMass = mass; | ||
return *this; | ||
} | ||
|
||
Particle ParticleBuilder::build() | ||
Particle ParticleBuilder::build() const | ||
{ | ||
return {}; | ||
return {mMass, mAcceleration, mVelocity, mPosition}; | ||
} | ||
|
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
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