From 95d3d1cb28f8a158c892ef10d4144447560843ff Mon Sep 17 00:00:00 2001 From: Lukas Reichwein Date: Mon, 15 Jul 2019 09:38:35 +0200 Subject: [PATCH] linked calculating the Determinants of the input Matrices to their Buttons --- .../matrixcalc/MatrixCalcController.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java b/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java index ee0cebb..e378eb1 100644 --- a/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java +++ b/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java @@ -9,7 +9,7 @@ public class MatrixCalcController { // Hier werden die fx:id Attribute verknuepft. @FXML - private Button multiplyButton, addButton, swapInputButton, substractButton, transposeButton; + private Button multiplyButton, addButton, DetAButton, DetBButton, substractButton, transposeButton; @FXML private Text errorText, outputText; @FXML @@ -105,5 +105,39 @@ public class MatrixCalcController { outputText.setTextAlignment(TextAlignment.CENTER); } }); + + DetAButton.setOnMouseClicked((event) -> { + MatrixCalcMath math = new MatrixCalcMath(); + MatrixCalcIOUtils util = new MatrixCalcIOUtils(); + + String stringMatrixA = matrixATextArea.getText(); + if (util.checkInput(stringMatrixA)) { + + double[][] matrixA = util.stringToMatrix(stringMatrixA); + double result = math.calcDeterminat(matrixA); + + String DisplayableString = Double.toString(result); + + outputText.setText(DisplayableString); + outputText.setTextAlignment(TextAlignment.CENTER); + } + }); + + DetBButton.setOnMouseClicked((event) -> { + MatrixCalcMath math = new MatrixCalcMath(); + MatrixCalcIOUtils util = new MatrixCalcIOUtils(); + + String stringMatrixB = matrixBTextArea.getText(); + if (util.checkInput(stringMatrixB)) { + + double[][] matrixB = util.stringToMatrix(stringMatrixB); + double result = math.calcDeterminat(matrixB); + + String DisplayableString = Double.toString(result); + + outputText.setText(DisplayableString); + outputText.setTextAlignment(TextAlignment.CENTER); + } + }); } } \ No newline at end of file