diff --git a/src/Acceleration.java b/src/Acceleration.java index 8a8aef6..5a9ae7e 100644 --- a/src/Acceleration.java +++ b/src/Acceleration.java @@ -1,37 +1,41 @@ import java.util.*; public class Acceleration { - private Map.Entry force; - private double mass; - private Velocity velocity; - private Onground onground; - private Map.Entry acceleration; - public void updateForce(Map.Entry force) { - this.force = force; - Map.Entry temp_l3; - if(this.onground.getOnground()) { - temp_l3 = new AbstractMap.SimpleEntry<>((force.getKey()/mass), 0.0); - } else { - temp_l3 = new AbstractMap.SimpleEntry<>((force.getKey()/mass), (force.getValue()/mass)); - } - acceleration = temp_l3; - velocity.updateAcceleration(acceleration); - } - public void updateMass(double mass) { - this.mass = mass; - Map.Entry temp_l6; - if(this.onground.getOnground()) { - temp_l6 = new AbstractMap.SimpleEntry<>((force.getKey()/mass), 0.0); - } else { - temp_l6 = new AbstractMap.SimpleEntry<>((force.getKey()/mass), (force.getValue()/mass)); - } - acceleration = temp_l6; - velocity.updateAcceleration(acceleration); - } - public Acceleration(Velocity velocity, Onground onground) { - this.onground = onground; - } - public Map.Entry getAcceleration() { - return acceleration; - } + private Pair force; + private double mass; + private Velocity velocity; + private Onground onground; + private Pair value; + + public void updateForce(Pair force) { + this.force = force; + Pari temp_l3; + if (this.onground.getOnground()) { + temp_l3 = new Pair<>((force.getFirst() / mass), 0.0); + } else { + temp_l3 = new Pair<>((force.getFirst() / mass), (force.getSecond() / mass)); + } + value = temp_l3; + velocity.updateAcceleration(value); + } + + public void updateMass(double mass) { + this.mass = mass; + Pair temp_l6; + if (this.onground.getOnground()) { + temp_l6 = new Pair<>((force.getFirst() / mass), 0.0); + } else { + temp_l6 = new Pair<>((force.getFirst() / mass), (force.getSecond() / mass)); + } + value = temp_l6; + velocity.updateAcceleration(value); + } + + public Acceleration(Velocity velocity, Onground onground) { + this.onground = onground; + } + + public Pair getValue() { + return value; + } } \ No newline at end of file