diff --git a/src/Acceleration.java b/src/Acceleration.java index 8a8aef6..5a9ae7e 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 value; + + 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)); + } + value = temp_l3; + velocity.updateAcceleration(value); + } + + 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)); + } + value = temp_l6; + velocity.updateAcceleration(value); + } + + public Acceleration(Velocity velocity, Onground onground) { + this.onground = onground; + } + + public Pair getValue() { + return value; + } } \ 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..ac7c47f 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 value; public Force(Acceleration acceleration) { this.acceleration = acceleration; } public void gravity(double y) { - this.force = new AbstractMap.SimpleEntry<>(0.0, y); - acceleration.updateForce(force); + this.value = new Pair<>(0.0, y); + acceleration.updateForce(value); } - public Map.Entry getForce() { - return force; + public Pair getValue() { + return value; } } \ 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/Ground.java b/src/Ground.java index f3dfaf8..249ad73 100644 --- a/src/Ground.java +++ b/src/Ground.java @@ -1,8 +1,8 @@ import java.util.*; public class Ground { - private boolean ground; - public boolean getGround() { - return ground; + private boolean value; + public boolean getValue() { + return value; } } \ No newline at end of file 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/Mass.java b/src/Mass.java index c381628..e98938a 100644 --- a/src/Mass.java +++ b/src/Mass.java @@ -2,15 +2,15 @@ public class Mass { private Acceleration acceleration; - private double mass; + private double value; public Mass(Acceleration acceleration) { this.acceleration = acceleration; } - public void setMass(double x) { - this.mass = x; - acceleration.updateMass(mass); + public void setValue(double x) { + this.value = x; + acceleration.updateMass(value); } - public double getMass() { - return mass; + public double getValue() { + return value; } } \ No newline at end of file diff --git a/src/Move.java b/src/Move.java index 5f99f99..0d18dbe 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 value; public Move(Velocity velocity) { this.velocity = velocity; } public void moveX(double x) { - this.move = new AbstractMap.SimpleEntry<>(x, this.move.getValue()); - velocity.updateMove(move); + this.value = new Pair<>(x, this.value.getSecond()); + velocity.updateMove(value); } public void moveY(double y) { - this.move = new AbstractMap.SimpleEntry<>(this.move.getKey(), y); + this.value = new Pair<>(this.value.getFirst(), y); } - public Map.Entry getMove() { - return move; + public Pair getValue() { + return value; } } \ 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/Pair.java b/src/Pair.java new file mode 100644 index 0000000..4c24770 --- /dev/null +++ b/src/Pair.java @@ -0,0 +1,19 @@ +import java.util.*; + +public class Pair { + private T first; + private T second; + + public Pair(T first, T second) { + this.first = first; + this.second = second; + } + + public T getFirst() { + return this.first; + } + + public T getSecond() { + return this.second; + } +} diff --git a/src/Position.java b/src/Position.java index e69ad66..e132696 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 value; + public void updateVelocity(Pair velocity) { + Pair temp_l4; + if(((this.ground.getGround()==true)&&((this.value.getSecond()+(0.01*velocity.getSecond()))<0.0))) { + temp_l4 = new Pair<>((this.value.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.value.getFirst()+(0.01*velocity.getFirst())), (this.value.getSecond()+(0.01*velocity.getSecond()))); } - position = temp_l4; + value = temp_l4; } public Position(Ground ground) { this.ground = ground; } - public Map.Entry getPosition() { - return position; + public Pair getValue() { + return value; } } \ No newline at end of file diff --git a/src/Time.java b/src/Time.java index cf5540a..ec23892 100644 --- a/src/Time.java +++ b/src/Time.java @@ -1,11 +1,11 @@ import java.util.*; public class Time { - private double time; + private double value; public void gravity(double y) { - this.time = (this.time+0.01); + this.value = (this.value +0.01); } - public double getTime() { - return time; + public double getValue() { + return value; } } \ No newline at end of file diff --git a/src/Velocity.java b/src/Velocity.java index 5522079..89bb343 100644 --- a/src/Velocity.java +++ b/src/Velocity.java @@ -1,37 +1,37 @@ 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 value; + 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; + temp_l0 = this.value; } - velocity = temp_l0; - position.updateVelocity(velocity); + value = temp_l0; + position.updateVelocity(value); } - 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.value.getSecond()<0.0))) { + temp_l2 = new Pair<>((this.value.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.value.getFirst()+(0.01*acceleration.getFirst())), (this.value.getSecond()+(0.01*acceleration.getSecond()))); } - velocity = temp_l2; - position.updateVelocity(velocity); + value = temp_l2; + position.updateVelocity(value); } public Velocity(Position position, Onground onground) { this.onground = onground; } - public Map.Entry getVelocity() { - return velocity; + public Pair getValue() { + return value; } } \ No newline at end of file