diff --git a/src/Acceleration.java b/src/Acceleration.java index 882c0d8..181922b 100644 --- a/src/Acceleration.java +++ b/src/Acceleration.java @@ -1,4 +1,5 @@ -import java.util.*; +import java.util.AbstractMap; +import java.util.Map; public class Acceleration { private double mass; @@ -9,15 +10,21 @@ public void updateMass(double mass) { this.mass = mass; - acceleration = (getOnground() ? new AbstractMap.SimpleEntry<>((force.getKey() / mass), 0.0) - : new AbstractMap.SimpleEntry<>((force.getKey() / mass), (force.getValue() / mass))); + + if (getOnground()) + acceleration = new AbstractMap.SimpleEntry<>((force.getKey() / mass), 0.0); + else + acceleration = new AbstractMap.SimpleEntry<>((force.getKey() / mass), (force.getValue() / mass)); velocity.updateAcceleration(acceleration); } public void updateForce(Map.Entry force) { this.force = force; - acceleration = (getOnground() ? new AbstractMap.SimpleEntry<>((force.getKey() / mass), 0.0) - : new AbstractMap.SimpleEntry<>((force.getKey() / mass), (force.getValue() / mass))); + + if (getOnground()) + acceleration = new AbstractMap.SimpleEntry<>((force.getKey() / mass), 0.0); + else + acceleration = new AbstractMap.SimpleEntry<>((force.getKey() / mass), (force.getValue() / mass)); velocity.updateAcceleration(acceleration); } diff --git a/src/Position.java b/src/Position.java index 1d3f1dd..e483702 100644 --- a/src/Position.java +++ b/src/Position.java @@ -1,4 +1,5 @@ -import java.util.*; +import java.util.AbstractMap; +import java.util.Map; public class Position { private Map.Entry velocity; @@ -7,18 +8,20 @@ public void updateVelocity(Map.Entry velocity) { this.velocity = velocity; - position = (getOnGround() - ? new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * velocity.getKey())), 0.0) - : new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * velocity.getKey())), - (this.position.getValue() + (0.01 * velocity.getValue())))); + if (getOnGround()) + position = new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * velocity.getKey())), 0.0); + else + new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * velocity.getKey())), + (this.position.getValue() + (0.01 * velocity.getValue()))); } public void updateGround(boolean ground) { this.ground = ground; - position = (getOnGround() - ? new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * velocity.getKey())), 0.0) - : new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * velocity.getKey())), - (this.position.getValue() + (0.01 * velocity.getValue())))); + if (getOnGround()) + position = new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * velocity.getKey())), 0.0); + else + new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * velocity.getKey())), + (this.position.getValue() + (0.01 * velocity.getValue()))); } public Map.Entry getPosition() { @@ -27,7 +30,7 @@ // AND private boolean getOnGround() { - if (!(ground == true)) + if (!ground) return false; return ((this.position.getValue() + (0.01 * velocity.getValue())) < 0.0); } diff --git a/src/Velocity.java b/src/Velocity.java index 7c54886..b8c87ff 100644 --- a/src/Velocity.java +++ b/src/Velocity.java @@ -1,4 +1,5 @@ -import java.util.*; +import java.util.AbstractMap; +import java.util.Map; public class Velocity { private Map.Entry acceleration; @@ -9,16 +10,19 @@ public void updateAcceleration(Map.Entry acceleration) { this.acceleration = acceleration; - velocity = (onJump() - ? new AbstractMap.SimpleEntry<>((this.velocity.getKey() + (0.01 * acceleration.getKey())), 0.0) - : new AbstractMap.SimpleEntry<>((this.velocity.getKey() + (0.01 * acceleration.getKey())), - (this.velocity.getValue() + (0.01 * acceleration.getValue())))); + if (onJump()) + velocity = new AbstractMap.SimpleEntry<>((this.velocity.getKey() + (0.01 * acceleration.getKey())), 0.0); + else + velocity = new AbstractMap.SimpleEntry<>((this.velocity.getKey() + (0.01 * acceleration.getKey())), + (this.velocity.getValue() + (0.01 * acceleration.getValue()))); position.updateVelocity(velocity); } public void updateMove(Map.Entry move) { this.move = move; - velocity = (onMove() ? move : this.velocity); + if (onMove()) + velocity = move; + position.updateVelocity(velocity); }