Newer
Older
JumpingGame / src / Acceleration.java
import java.util.*;

public class Acceleration {
	private double mass;
	private Map.Entry<Double, Double> force;
	private Velocity velocity;
	private Onground onground;
	private Map.Entry<Double, Double> acceleration;

	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)));
		velocity.updateAcceleration(acceleration);
	}

	public void updateForce(Map.Entry<Double, Double> force) {
		this.force = force;
		acceleration = (getOnground() ? new AbstractMap.SimpleEntry<>((force.getKey() / mass), 0.0)
				: new AbstractMap.SimpleEntry<>((force.getKey() / mass), (force.getValue() / mass)));
		velocity.updateAcceleration(acceleration);
	}

	public Acceleration(Velocity velocity, Onground onground) {
		this.onground = onground;
	}

	public Map.Entry<Double, Double> getAcceleration() {
		return acceleration;
	}

	private boolean getOnground() {
		return (this.onground.getOnground());
	}
}