Skip to content
Snippets Groups Projects
Commit 525aeda1 authored by Mikkel Marstein's avatar Mikkel Marstein
Browse files

check if input was string

parent 0396a892
No related branches found
No related tags found
No related merge requests found
...@@ -27,10 +27,15 @@ public class AppController { ...@@ -27,10 +27,15 @@ public class AppController {
} }
private double getInput() { private double getInput() {
if(input.getText().isEmpty()) String txt=input.getText();
if(txt.isEmpty())
return 0.0; return 0.0;
try {
return Double.parseDouble(input.getText()); double nr = Double.parseDouble(txt);
return nr;
} catch(NumberFormatException e){
return 0.0;
}
} }
@FXML @FXML
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment