diff --git a/src/Acceleration.java b/src/Acceleration.java index 8a8aef6..f3b962d 100644 --- a/src/Acceleration.java +++ b/src/Acceleration.java @@ -1,37 +1,41 @@ import java.util.*; public class Acceleration { - private Map.Entry force; - private double mass; - private Velocity velocity; - private Onground onground; - private Map.Entry acceleration; - public void updateForce(Map.Entry force) { - this.force = force; - Map.Entry temp_l3; - if(this.onground.getOnground()) { - temp_l3 = new AbstractMap.SimpleEntry<>((force.getKey()/mass), 0.0); - } else { - temp_l3 = new AbstractMap.SimpleEntry<>((force.getKey()/mass), (force.getValue()/mass)); - } - acceleration = temp_l3; - velocity.updateAcceleration(acceleration); - } - public void updateMass(double mass) { - this.mass = mass; - Map.Entry temp_l6; - if(this.onground.getOnground()) { - temp_l6 = new AbstractMap.SimpleEntry<>((force.getKey()/mass), 0.0); - } else { - temp_l6 = new AbstractMap.SimpleEntry<>((force.getKey()/mass), (force.getValue()/mass)); - } - acceleration = temp_l6; - velocity.updateAcceleration(acceleration); - } - public Acceleration(Velocity velocity, Onground onground) { - this.onground = onground; - } - public Map.Entry getAcceleration() { - return acceleration; - } + private Pair force; + private double mass; + private Velocity velocity; + private Onground onground; + private Pair acceleration; + + public void updateForce(Pair force) { + this.force = force; + Pari temp_l3; + if (this.onground.getOnground()) { + temp_l3 = new Pair<>((force.getFirst() / mass), 0.0); + } else { + temp_l3 = new Pair<>((force.getFirst() / mass), (force.getSecond() / mass)); + } + acceleration = temp_l3; + velocity.updateAcceleration(acceleration); + } + + public void updateMass(double mass) { + this.mass = mass; + Pair temp_l6; + if (this.onground.getOnground()) { + temp_l6 = new Pair<>((force.getFirst() / mass), 0.0); + } else { + temp_l6 = new Pair<>((force.getFirst() / mass), (force.getSecond() / mass)); + } + acceleration = temp_l6; + velocity.updateAcceleration(acceleration); + } + + public Acceleration(Velocity velocity, Onground onground) { + this.onground = onground; + } + + public Pair getAcceleration() { + return acceleration; + } } \ No newline at end of file diff --git a/src/Clear.java b/src/Clear.java index 336e723..f60d398 100644 --- a/src/Clear.java +++ b/src/Clear.java @@ -7,7 +7,7 @@ } public boolean getClear() { boolean temp_l1; - if((this.position.getPosition().getKey()>100.0)) { + if((this.position.getPosition().getFirst()>100.0)) { temp_l1 = true; } else { temp_l1 = false; diff --git a/src/Force.java b/src/Force.java index e379404..43ddf98 100644 --- a/src/Force.java +++ b/src/Force.java @@ -2,15 +2,15 @@ public class Force { private Acceleration acceleration; - private Map.Entry force; + private Pair force; public Force(Acceleration acceleration) { this.acceleration = acceleration; } public void gravity(double y) { - this.force = new AbstractMap.SimpleEntry<>(0.0, y); + this.force = new Pair<>(0.0, y); acceleration.updateForce(force); } - public Map.Entry getForce() { + public Pair getForce() { return force; } } \ No newline at end of file diff --git a/src/Gameover.java b/src/Gameover.java index 5f17032..5069af2 100644 --- a/src/Gameover.java +++ b/src/Gameover.java @@ -7,7 +7,7 @@ } public boolean getGameover() { boolean temp_l5; - if((this.position.getPosition().getValue()<-(1.0))) { + if((this.position.getPosition().getSecond()<-(1.0))) { temp_l5 = true; } else { temp_l5 = false; diff --git a/src/JumpGame.java b/src/JumpGame.java index 8684695..ffc6f34 100644 --- a/src/JumpGame.java +++ b/src/JumpGame.java @@ -25,10 +25,10 @@ public void setMass(double x) { this.mass.setMass(x); } - public Map.Entry getAcceleration() { + public Pair getAcceleration() { return acceleration.getAcceleration(); } - public Map.Entry getMove() { + public Pair getMove() { return move.getMove(); } public double getMass() { @@ -40,13 +40,13 @@ public boolean getGround() { return ground.getGround(); } - public Map.Entry getForce() { + public Pair getForce() { return force.getForce(); } - public Map.Entry getVelocity() { + public Pair getVelocity() { return velocity.getVelocity(); } - public Map.Entry getPosition() { + public Pair getPosition() { return position.getPosition(); } public boolean getOnground() { diff --git a/src/Move.java b/src/Move.java index 5f99f99..02f52d2 100644 --- a/src/Move.java +++ b/src/Move.java @@ -2,18 +2,18 @@ public class Move { private Velocity velocity; - private Map.Entry move; + private Pair move; public Move(Velocity velocity) { this.velocity = velocity; } public void moveX(double x) { - this.move = new AbstractMap.SimpleEntry<>(x, this.move.getValue()); + this.move = new Pair<>(x, this.move.getSecond()); velocity.updateMove(move); } public void moveY(double y) { - this.move = new AbstractMap.SimpleEntry<>(this.move.getKey(), y); + this.move = new Pair<>(this.move.getFirst(), y); } - public Map.Entry getMove() { + public Pair getMove() { return move; } } \ No newline at end of file diff --git a/src/Onground.java b/src/Onground.java index 694d757..8ba9c2b 100644 --- a/src/Onground.java +++ b/src/Onground.java @@ -8,6 +8,6 @@ this.position = position; } public boolean getOnground() { - return ((this.ground.getGround()==true)&&(this.position.getPosition().getValue()<=0.0)); + return ((this.ground.getGround()==true)&&(this.position.getPosition().getSecond()<=0.0)); } } \ No newline at end of file diff --git a/src/Position.java b/src/Position.java index e69ad66..e102308 100644 --- a/src/Position.java +++ b/src/Position.java @@ -2,20 +2,20 @@ public class Position { private Ground ground; - private Map.Entry position; - public void updateVelocity(Map.Entry velocity) { - Map.Entry temp_l4; - if(((this.ground.getGround()==true)&&((this.position.getValue()+(0.01*velocity.getValue()))<0.0))) { - temp_l4 = new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), 0.0); + private Pair position; + public void updateVelocity(Pair velocity) { + Pair temp_l4; + if(((this.ground.getGround()==true)&&((this.position.getSecond()+(0.01*velocity.getSecond()))<0.0))) { + temp_l4 = new Pair<>((this.position.getFirst()+(0.01*velocity.getFirst())), 0.0); } else { - temp_l4 = new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), (this.position.getValue()+(0.01*velocity.getValue()))); + temp_l4 = new Pair<>((this.position.getFirst()+(0.01*velocity.getFirst())), (this.position.getSecond()+(0.01*velocity.getSecond()))); } position = temp_l4; } public Position(Ground ground) { this.ground = ground; } - public Map.Entry getPosition() { + public Pair getPosition() { return position; } } \ No newline at end of file diff --git a/src/Velocity.java b/src/Velocity.java index 5522079..af0c2c7 100644 --- a/src/Velocity.java +++ b/src/Velocity.java @@ -1,15 +1,15 @@ import java.util.*; public class Velocity { - private Map.Entry move; - private Map.Entry acceleration; + private Pair move; + private Pair acceleration; private Position position; private Onground onground; - private Map.Entry velocity; - public void updateMove(Map.Entry move) { + private Pair velocity; + public void updateMove(Pair move) { this.move = move; - Map.Entry temp_l0; - if((this.onground.getOnground()&&(move.getValue()>=0.0))) { + Pair temp_l0; + if((this.onground.getOnground()&&(move.getSecond()>=0.0))) { temp_l0 = move; } else { temp_l0 = this.velocity; @@ -17,13 +17,13 @@ velocity = temp_l0; position.updateVelocity(velocity); } - public void updateAcceleration(Map.Entry acceleration) { + public void updateAcceleration(Pair acceleration) { this.acceleration = acceleration; - Map.Entry temp_l2; - if((this.onground.getOnground()&&(this.velocity.getValue()<0.0))) { - temp_l2 = new AbstractMap.SimpleEntry<>((this.velocity.getKey()+(0.01*acceleration.getKey())), 0.0); + Pair temp_l2; + if((this.onground.getOnground()&&(this.velocity.getSecond()<0.0))) { + temp_l2 = new Pair<>((this.velocity.getFirst()+(0.01*acceleration.getFirst())), 0.0); } else { - temp_l2 = new AbstractMap.SimpleEntry<>((this.velocity.getKey()+(0.01*acceleration.getKey())), (this.velocity.getValue()+(0.01*acceleration.getValue()))); + temp_l2 = new Pair<>((this.velocity.getFirst()+(0.01*acceleration.getFirst())), (this.velocity.getSecond()+(0.01*acceleration.getSecond()))); } velocity = temp_l2; position.updateVelocity(velocity); @@ -31,7 +31,7 @@ public Velocity(Position position, Onground onground) { this.onground = onground; } - public Map.Entry getVelocity() { + public Pair getVelocity() { return velocity; } } \ No newline at end of file