From 985f3b0f15463f4d40dac0dff66b54a84442e97c Mon Sep 17 00:00:00 2001 From: iMoHax Date: Tue, 5 Apr 2016 13:06:50 +0300 Subject: [PATCH] don't compute unladen ship mass if changes cargo or tank --- .../main/java/ru/trader/model/ProfileModel.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/client/src/main/java/ru/trader/model/ProfileModel.java b/client/src/main/java/ru/trader/model/ProfileModel.java index 9ff9f6f..5ac38c4 100644 --- a/client/src/main/java/ru/trader/model/ProfileModel.java +++ b/client/src/main/java/ru/trader/model/ProfileModel.java @@ -157,7 +157,9 @@ public class ProfileModel { } public void setShipMass(double shipMass) { - updateUnladenMass(shipMass); + double unladenMass = shipMass - profile.getShip().getTank() - profile.getShip().getCargo(); + profile.getShip().setMass(unladenMass); + this.shipMass.set(profile.getShip().getLadenMass()); } public double getShipTank() { @@ -170,7 +172,7 @@ public class ProfileModel { public void setShipTank(double shipTank) { profile.getShip().setTank(shipTank); - updateUnladenMass(getShipMass()); + this.shipMass.set(profile.getShip().getLadenMass()); this.shipTank.set(shipTank); } @@ -184,7 +186,7 @@ public class ProfileModel { public void setShipCargo(int shipCargo) { profile.getShip().setCargo(shipCargo); - updateUnladenMass(getShipMass()); + this.shipMass.set(profile.getShip().getLadenMass()); this.shipCargo.set(shipCargo); } @@ -229,12 +231,6 @@ public class ProfileModel { route.setValue(null); } - private void updateUnladenMass(double ladenMass){ - double unladenMass = ladenMass - profile.getShip().getTank() - profile.getShip().getCargo(); - profile.getShip().setMass(unladenMass); - this.shipMass.set(profile.getShip().getLadenMass()); - } - private void refresh(){ name.setValue(profile.getName()); balance.setValue(profile.getBalance());