Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package Vraag2;
- import java.net.URL;
- import java.util.ResourceBundle;
- import javafx.fxml.FXML;
- import javafx.fxml.Initializable;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.control.TextField;
- import javafx.scene.input.MouseEvent;
- /**
- * FXML Controller class
- *
- * @author Amadeo
- */
- public class FXML2Controller implements Initializable {
- double fGetal1,fGetal2,fResultaat;
- private String sBewerking;
- @FXML
- private Button btnEen;
- @FXML
- private Button btnTwee;
- @FXML
- private Button btnDrie;
- @FXML
- private Button btnVier;
- @FXML
- private Button btnVijf;
- @FXML
- private Button btnZes;
- @FXML
- private Button btnZeven;
- @FXML
- private Button btnAcht;
- @FXML
- private Button btnNegen;
- @FXML
- private Button btnNul;
- @FXML
- private Button btnKomma;
- @FXML
- private Button btnClear;
- @FXML
- private Button btnOptellen;
- @FXML
- private Button btnAftrekken;
- @FXML
- private Button btnVermenigvuldig;
- @FXML
- private Button btnDelen;
- @FXML
- private Button btnMacht;
- @FXML
- private Button btnModule;
- @FXML
- private Button btnResultaat;
- @FXML
- private TextField txtDisplay;
- @FXML
- private Label lblResultaat;
- /**
- * Initializes the controller class.
- */
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- // TODO
- }
- @FXML
- private void clicked_cijfer(MouseEvent event)
- {
- txtDisplay.setText(txtDisplay.getText() + ((Button)event.getSource()).getText());
- }
- @FXML
- private void clicked_bewerking(MouseEvent event)
- {
- // if(sBewerking.isEmpty())
- // {
- // if (txtDisplay.getText().isEmpty())
- // {
- fGetal1 = Double.parseDouble(txtDisplay.getText());
- sBewerking = ((Button)event.getSource()).getText();
- txtDisplay.setText("");
- lblResultaat.setText(String.valueOf(fGetal1));
- // }
- // }
- }
- @FXML
- private void clicked_isGelijkAan(MouseEvent event)
- {
- if(txtDisplay.getText().isEmpty())
- {
- fGetal2 = Double.parseDouble(txtDisplay.getText());
- // if(fGetal2 == 0 && sBewerking == "\\")
- // {
- // //error
- // }
- // else
- // {
- switch(sBewerking)
- {
- case "+":
- fResultaat = fGetal1 + fGetal2;
- break;
- case "-":
- fResultaat = fGetal1 - fGetal2;
- break;
- case "*":
- fResultaat = fGetal1 * fGetal2;
- break;
- case "/":
- fResultaat = fGetal1 / fGetal2;
- break;
- case "^":
- fResultaat = Math.pow(fGetal1,fGetal2);
- break;
- case "Mod":
- fResultaat = fGetal1 % fGetal2;
- break;
- default: lblResultaat.setText("error");
- break;
- }
- if (sBewerking.equals("\\"))
- {
- lblResultaat.setText(String.valueOf((int)fGetal1) + sBewerking + String.valueOf((int)fGetal2)
- + " = " + String.valueOf((int)fResultaat));
- }
- else
- {
- lblResultaat.setText(String.valueOf(fGetal1) + " " + sBewerking + " " + String.valueOf(fGetal2)
- + " = " + String.valueOf(fResultaat));
- }
- }
- }
- @FXML
- private void clicked_clearTekst(MouseEvent event) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement