summaryrefslogtreecommitdiffstats
path: root/src/de/fhswf/in/inf/upnfx
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/fhswf/in/inf/upnfx')
-rw-r--r--src/de/fhswf/in/inf/upnfx/util/UPN.java6
-rw-r--r--src/de/fhswf/in/inf/upnfx/view/MainViewController.java15
2 files changed, 13 insertions, 8 deletions
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<String, Operator> 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