diff --git a/src/Acceleration.java b/src/Acceleration.java index 3bccc68..37babc8 100644 --- a/src/Acceleration.java +++ b/src/Acceleration.java @@ -1,25 +1,30 @@ -import java.util.*; - public class Acceleration { private double mass; - private Map.Entry force; + private Pair force; private Velocity velocity; private Onground onground; - private Map.Entry acceleration; + private Pair acceleration; + public void updateMass(double mass) { this.mass = mass; - acceleration = (this.onground.getOnground() ? new AbstractMap.SimpleEntry<>((force.getKey()/mass), 0.0) : new AbstractMap.SimpleEntry<>((force.getKey()/mass), (force.getValue()/mass))); + acceleration = (this.onground.getOnground() ? new Pair<>((force.getX() / mass), 0.0) + : new Pair<>((force.getX() / mass), (force.getY() / mass))); velocity.updateAcceleration(acceleration); } - public void updateForce(Map.Entry force) { + + public void updateForce(Pair force) { this.force = force; - acceleration = (this.onground.getOnground() ? new AbstractMap.SimpleEntry<>((force.getKey()/mass), 0.0) : new AbstractMap.SimpleEntry<>((force.getKey()/mass), (force.getValue()/mass))); + acceleration = (this.onground.getOnground() ? new Pair<>((force.getX() / mass), 0.0) + : new Pair<>((force.getX() / mass), (force.getY() / mass))); velocity.updateAcceleration(acceleration); } + public Acceleration(Velocity velocity, Onground onground) { + this.velocity = velocity; this.onground = onground; } - public Map.Entry getAcceleration() { + + public Pair getAcceleration() { return acceleration; } } \ No newline at end of file