|
@@ -115,7 +115,11 @@ public class CalcSkin extends Application {
|
115
|
115
|
} else if ("=".equals(s)) {
|
116
|
116
|
makeEqualsButton(button);
|
117
|
117
|
} else if ("x2".equals(s)) {
|
118
|
|
-
|
|
118
|
+ makeSquareButton(button);
|
|
119
|
+ } else if ("√x".equals(s)) {
|
|
120
|
+ makeRootButton(button);
|
|
121
|
+ } else if ("1/x".equals(button)){
|
|
122
|
+ makeInverseButton(button);
|
119
|
123
|
}
|
120
|
124
|
}
|
121
|
125
|
|
|
@@ -130,10 +134,10 @@ public class CalcSkin extends Application {
|
130
|
134
|
case "-": triggerOp.set(Op.SUBTRACT); break;
|
131
|
135
|
case "*": triggerOp.set(Op.MULTIPLY); break;
|
132
|
136
|
case "/": triggerOp.set(Op.DIVIDE); break;
|
133
|
|
- case "x2":triggerOp.set(Op.SQUARE); break;
|
134
|
|
- case "√x":triggerOp.set(Op.ROOT); break;
|
135
|
|
- case "1/x":triggerOp.set(Op.INVERSE); break;
|
136
|
|
- case "x^y":triggerOp.set(Op.EXPO); break;
|
|
137
|
+ //case "x2":triggerOp.set(Op.SQUARE); break;
|
|
138
|
+ //case "√x":triggerOp.set(Op.ROOT); break;
|
|
139
|
+ //case "1/x":triggerOp.set(Op.INVERSE); break;
|
|
140
|
+ // case "x^y":triggerOp.set(Op.EXPO); break;
|
137
|
141
|
|
138
|
142
|
}
|
139
|
143
|
return triggerOp;
|
|
@@ -173,6 +177,36 @@ public class CalcSkin extends Application {
|
173
|
177
|
});
|
174
|
178
|
}
|
175
|
179
|
|
|
180
|
+ private void makeSquareButton(Button button) {
|
|
181
|
+ button.setStyle("-fx-base: #d896ff;");
|
|
182
|
+ button.setOnAction(new EventHandler<ActionEvent>() {
|
|
183
|
+ @Override
|
|
184
|
+ public void handle(ActionEvent actionEvent) {
|
|
185
|
+ currentValue.set(Math.pow(currentValue.get(), 2));
|
|
186
|
+ }
|
|
187
|
+ });
|
|
188
|
+ }
|
|
189
|
+
|
|
190
|
+ private void makeRootButton(Button button) {
|
|
191
|
+ button.setStyle("-fx-base: #3b43ff;");
|
|
192
|
+ button.setOnAction(new EventHandler<ActionEvent>() {
|
|
193
|
+ @Override
|
|
194
|
+ public void handle(ActionEvent actionEvent) {
|
|
195
|
+ currentValue.set(Math.sqrt(currentValue.get()));
|
|
196
|
+ }
|
|
197
|
+ });
|
|
198
|
+ }
|
|
199
|
+
|
|
200
|
+ private void makeInverseButton(Button button) {
|
|
201
|
+ button.setStyle("-fx-base: #d896ff;");
|
|
202
|
+ button.setOnAction(new EventHandler<ActionEvent>() {
|
|
203
|
+ @Override
|
|
204
|
+ public void handle(ActionEvent actionEvent) {
|
|
205
|
+ currentValue.set(calcEngine.inverse(currentValue.get()));
|
|
206
|
+ }
|
|
207
|
+ });
|
|
208
|
+ }
|
|
209
|
+
|
176
|
210
|
private void makeClearButton(Button button) {
|
177
|
211
|
button.setStyle("-fx-base: rgba(169,255,131,1);");
|
178
|
212
|
button.setOnAction(new EventHandler<ActionEvent>() {
|
|
@@ -196,8 +230,8 @@ public class CalcSkin extends Application {
|
196
|
230
|
case MULTIPLY: currentValue.set(calcEngine.multiply(previousValue.get(), currentValue.get())); break;
|
197
|
231
|
case DIVIDE: currentValue.set(calcEngine.divide(previousValue.get(), currentValue.get())); break;
|
198
|
232
|
//case SQUARE: currentValue.set(calcEngine.square(currentValue.get())); break;
|
199
|
|
- case ROOT: currentValue.set(calcEngine.squareRoot(currentValue.get())); break;
|
200
|
|
- case INVERSE: currentValue.set(calcEngine.inverse(currentValue.get())); break;
|
|
233
|
+ //case ROOT: currentValue.set(calcEngine.squareRoot(currentValue.get())); break;
|
|
234
|
+ //case INVERSE: currentValue.set(calcEngine.inverse(currentValue.get())); break;
|
201
|
235
|
case EXPO: currentValue.set(calcEngine.exponent(previousValue.get(), currentValue.get())); break;
|
202
|
236
|
}
|
203
|
237
|
}
|