Skip to content

Instantly share code, notes, and snippets.

@vincentius15
Last active March 9, 2019 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincentius15/42c5cdfe1e033d6452454f18e4191c25 to your computer and use it in GitHub Desktop.
Save vincentius15/42c5cdfe1e033d6452454f18e4191c25 to your computer and use it in GitHub Desktop.
public class MovingObject {
private int initialVelocity;
private int duration;
private int acceleration;
private int mass;
public MovingObject(int initialVelocity, int duration, int acceleration, int mass) {
this.initialVelocity = initialVelocity;
this.duration = duration;
this.acceleration = acceleration;
this.mass = mass;
}
public double displacement(){
return (initialVelocity*duration)+(0.5*acceleration*Math.pow(duration,2));
}
public double currentMomentum(){
return mass*initialVelocity;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment