From 96b0868fb4a95ceabd4aeda992f6a90a44ae521f Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Mon, 15 Jun 2015 14:21:27 +0200 Subject: Remove a Sysout and fix a few problems with 0 --- src/de/fhswf/in/inf/upnfx/util/UPN.java | 6 ++---- src/de/fhswf/in/inf/upnfx/view/MainViewController.java | 15 +++++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/de/fhswf/in/inf') diff --git a/src/de/fhswf/in/inf/upnfx/util/UPN.java b/src/de/fhswf/in/inf/upnfx/util/UPN.java index bc773d5..1918ba6 100644 --- a/src/de/fhswf/in/inf/upnfx/util/UPN.java +++ b/src/de/fhswf/in/inf/upnfx/util/UPN.java @@ -37,15 +37,13 @@ public class UPN { throw new IllegalArgumentException("Operator can't be null."); } - - System.out.println(operator); - + lastX = upnStack.peek(); operator.eval(upnStack); } - + public final void addDouble(Double newVal) { if (newVal == null) diff --git a/src/de/fhswf/in/inf/upnfx/view/MainViewController.java b/src/de/fhswf/in/inf/upnfx/view/MainViewController.java index 6a9a115..1ee9173 100644 --- a/src/de/fhswf/in/inf/upnfx/view/MainViewController.java +++ b/src/de/fhswf/in/inf/upnfx/view/MainViewController.java @@ -80,7 +80,7 @@ public class MainViewController private ObservableDoubleStack upnStack = upnClass.getStack(); private StringProperty newNumber = new SimpleStringProperty(""); - + private static Map operators = new HashMap<>(); static @@ -103,7 +103,7 @@ public class MainViewController { txtField.textProperty().addListener(e -> { btnComma.setDisable(!newNumber.isEmpty().get() && newNumber.get().contains(".")); - btnZero.setDisable(!newNumber.isEmpty().get() && !newNumber.get().contains(".") && newNumber.get().contains("0")); + btnZero.setDisable(!newNumber.isEmpty().get() && !newNumber.get().contains(".") && newNumber.get().startsWith("0")); }); newNumber.addListener(e -> { @@ -114,7 +114,7 @@ public class MainViewController if(!newNumber.isEmpty().get()) { txtField.setText(newNumber.get()); - + btnPlus.setDisable(upnStack.size() < 1); btnMinus.setDisable(upnStack.size() < 1); btnMul.setDisable(upnStack.size() < 1); @@ -231,7 +231,14 @@ public class MainViewController private void handleNumber(String number) { - newNumber.set(newNumber.concat(number).get()); + if(newNumber.get().equals("0") && !number.equals(".")) + { + newNumber.set(number); + } + else + { + newNumber.set(newNumber.concat(number).get()); + } } @FXML -- cgit v1.2.3-70-g09d2