|
@@ -34,7 +34,7 @@ public class CalcSkin extends Application {
|
34
|
34
|
|
35
|
35
|
private DoubleProperty previousValue = new SimpleDoubleProperty();
|
36
|
36
|
private DoubleProperty currentValue = new SimpleDoubleProperty();
|
37
|
|
- private CalcEngine calcEngine = new CalcEngine();
|
|
37
|
+ private ScientificCalculator scientificCalculator = new ScientificCalculator();
|
38
|
38
|
|
39
|
39
|
private enum Op { NOOP, ADD, SUBTRACT, MULTIPLY, DIVIDE }
|
40
|
40
|
|
|
@@ -154,10 +154,10 @@ public class CalcSkin extends Application {
|
154
|
154
|
@Override
|
155
|
155
|
public void handle(ActionEvent actionEvent) {
|
156
|
156
|
if (curOp == Op.NOOP) {
|
157
|
|
- currentValue.set(currentValue.get() * 10 + Integer.parseInt(s));
|
|
157
|
+ currentValue.set(currentValue.get() * 10 + Double.parseDouble(s));
|
158
|
158
|
} else {
|
159
|
159
|
previousValue.set(currentValue.get());
|
160
|
|
- currentValue.set(Integer.parseInt(s));
|
|
160
|
+ currentValue.set(Double.parseDouble(s));
|
161
|
161
|
stackOp = curOp;
|
162
|
162
|
curOp = Op.NOOP;
|
163
|
163
|
}
|
|
@@ -181,10 +181,10 @@ public class CalcSkin extends Application {
|
181
|
181
|
@Override
|
182
|
182
|
public void handle(ActionEvent actionEvent) {
|
183
|
183
|
switch (stackOp) {
|
184
|
|
- case ADD: currentValue.set(calcEngine.add(previousValue.get(), currentValue.get())); break;
|
185
|
|
- case SUBTRACT: currentValue.set(calcEngine.subtract(previousValue.get(), currentValue.get())); break;
|
186
|
|
- case MULTIPLY: currentValue.set(calcEngine.multiply(previousValue.get(), currentValue.get())); break;
|
187
|
|
- case DIVIDE: currentValue.set(calcEngine.divide(previousValue.get(), currentValue.get())); break;
|
|
184
|
+ case ADD: currentValue.set(scientificCalculator.add(previousValue.get(), currentValue.get())); break;
|
|
185
|
+ case SUBTRACT: currentValue.set(scientificCalculator.subtract(previousValue.get(), currentValue.get())); break;
|
|
186
|
+ case MULTIPLY: currentValue.set(scientificCalculator.multiply(previousValue.get(), currentValue.get())); break;
|
|
187
|
+ case DIVIDE: currentValue.set(scientificCalculator.divide(previousValue.get(), currentValue.get())); break;
|
188
|
188
|
}
|
189
|
189
|
}
|
190
|
190
|
});
|