public class Velocity { private Pair<Double> acceleration; private Pair<Double> move; private Position position; private Onground onground; private Pair<Double> velocity; public void updateAcceleration(Pair<Double> acceleration) { this.acceleration = acceleration; velocity = ((this.onground.getOnground() && (this.velocity.getY() < 0.0)) ? new Pair<>(this.velocity.getX() + (0.01 * acceleration.getX()), 0.0) : new Pair<>(this.velocity.getX() + (0.01 * acceleration.getX()), (this.velocity.getY() + (0.01 * acceleration.getY())))); position.updateVelocity(velocity); } public void updateMove(Pair<Double> move) { this.move = move; velocity = ((this.onground.getOnground() && (move.getY() >= 0.0)) ? move : this.velocity); position.updateVelocity(velocity); } public Velocity(Position position, Onground onground) { this.position = position; this.onground = onground; } public Pair<Double> getVelocity() { return velocity; } }