import java.util.*; public class Position { private Map.Entry<Double, Double> velocity; private boolean ground; private Map.Entry<Double, Double> position; public void updateVelocity(Map.Entry<Double, Double> 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())))); } 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())))); } public Map.Entry<Double, Double> getPosition() { return position; } // AND private boolean getOnGround() { if (!(ground == true)) return false; return ((this.position.getValue() + (0.01 * velocity.getValue())) < 0.0); } }