diff --git a/src/Acceleration.java b/src/Acceleration.java new file mode 100644 index 0000000..c60c686 --- /dev/null +++ b/src/Acceleration.java @@ -0,0 +1,41 @@ +import java.util.*; + +public class Acceleration { + private double massValue; + private Map.Entry forceValue; + private Velocity velocity; + private Onground onground; + private Map.Entry value; + + public void updateByMass(double mass) { + this.massValue = mass; + Map.Entry temp_l0; + if (this.onground.getOnground()) { + temp_l0 = new AbstractMap.SimpleEntry<>((forceValue.getKey() / mass), 0.0); + } else { + temp_l0 = new AbstractMap.SimpleEntry<>((forceValue.getKey() / mass), (forceValue.getValue() / mass)); + } + value = temp_l0; + velocity.updateByAcceleration(value); + } + + public void updateByForce(Map.Entry force) { + this.forceValue = force; + Map.Entry temp_l1; + if (this.onground.getOnground()) { + temp_l1 = new AbstractMap.SimpleEntry<>((force.getKey() / massValue), 0.0); + } else { + temp_l1 = new AbstractMap.SimpleEntry<>((force.getKey() / massValue), (force.getValue() / massValue)); + } + value = temp_l1; + velocity.updateByAcceleration(value); + } + + public Acceleration(Velocity velocity, Onground onground) { + this.onground = onground; + } + + public Map.Entry getValue() { + return value; + } +} \ No newline at end of file