From 638ecdb125849606ad988ef5f4934898b78c4ce3 Mon Sep 17 00:00:00 2001 From: Lukas Reichwein Date: Mon, 15 Jul 2019 09:20:02 +0200 Subject: [PATCH] connected Matrix Substraction to the substract Button --- .../matrixcalc/MatrixCalcController.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java b/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java index 9adbce5..ee0cebb 100644 --- a/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java +++ b/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java @@ -86,5 +86,24 @@ public class MatrixCalcController { outputText.setTextAlignment(TextAlignment.CENTER); } }); + + substractButton.setOnMouseClicked((event) -> { + MatrixCalcMath math = new MatrixCalcMath(); + MatrixCalcIOUtils util = new MatrixCalcIOUtils(); + + String stringMatrixA = matrixATextArea.getText(); + String stringMatrixB = matrixBTextArea.getText(); + if (util.checkInput(stringMatrixA) && util.checkInput(stringMatrixB)) { + + double[][] matrixA = util.stringToMatrix(stringMatrixA); + double[][] matrixB = util.stringToMatrix(stringMatrixB); + double[][] result = math.matrixSubstraction(matrixA, matrixB); + + String DisplayableString = util.outputMatrixToOutputText(result); + + outputText.setText(DisplayableString); + outputText.setTextAlignment(TextAlignment.CENTER); + } + }); } } \ No newline at end of file