|
@ -93,16 +93,47 @@ public class MatrixCalcController { |
|
|
|
|
|
|
|
|
String stringMatrixA = matrixATextArea.getText(); |
|
|
String stringMatrixA = matrixATextArea.getText(); |
|
|
String stringMatrixB = matrixBTextArea.getText(); |
|
|
String stringMatrixB = matrixBTextArea.getText(); |
|
|
if (util.checkInput(stringMatrixA) && util.checkInput(stringMatrixB)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean stop = false; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
util.checkInput(stringMatrixA); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
stop = true; |
|
|
|
|
|
|
|
|
|
|
|
outputText.setText(e.getMessage() + "A"); |
|
|
|
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
util.checkInput(stringMatrixB); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
stop = true; |
|
|
|
|
|
|
|
|
|
|
|
outputText.setText(e.getMessage() + "B"); |
|
|
|
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (util.checkInput(stringMatrixA) && util.checkInput(stringMatrixB) && !stop) { |
|
|
|
|
|
|
|
|
double[][] matrixA = util.stringToMatrix(stringMatrixA); |
|
|
double[][] matrixA = util.stringToMatrix(stringMatrixA); |
|
|
double[][] matrixB = util.stringToMatrix(stringMatrixB); |
|
|
double[][] matrixB = util.stringToMatrix(stringMatrixB); |
|
|
double[][] result = math.matrixSubstraction(matrixA, matrixB); |
|
|
|
|
|
|
|
|
|
|
|
String DisplayableString = util.outputMatrixToOutputText(result); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
double[][] result = math.matrixSubstraction(matrixA, matrixB); |
|
|
|
|
|
|
|
|
|
|
|
String DisplayableString = util.outputMatrixToOutputText(result); |
|
|
|
|
|
|
|
|
|
|
|
outputText.setText(DisplayableString); |
|
|
|
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
|
|
|
outputText.setText(e.getMessage()); |
|
|
|
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outputText.setText(DisplayableString); |
|
|
|
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -111,16 +142,35 @@ public class MatrixCalcController { |
|
|
MatrixCalcIOUtils util = new MatrixCalcIOUtils(); |
|
|
MatrixCalcIOUtils util = new MatrixCalcIOUtils(); |
|
|
|
|
|
|
|
|
String stringMatrixA = matrixATextArea.getText(); |
|
|
String stringMatrixA = matrixATextArea.getText(); |
|
|
if (util.checkInput(stringMatrixA)) { |
|
|
|
|
|
|
|
|
|
|
|
double[][] matrixA = util.stringToMatrix(stringMatrixA); |
|
|
|
|
|
double result = math.calcDeterminat(matrixA); |
|
|
|
|
|
|
|
|
boolean stop = false; |
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
String DisplayableString = Double.toString(result); |
|
|
|
|
|
|
|
|
util.checkInput(stringMatrixA); |
|
|
|
|
|
|
|
|
outputText.setText(DisplayableString); |
|
|
|
|
|
|
|
|
} catch (IllegalArgumentException e) { |
|
|
|
|
|
stop = true; |
|
|
|
|
|
|
|
|
|
|
|
outputText.setText(e.getMessage()); |
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
} |
|
|
} |
|
|
|
|
|
if (util.checkInput(stringMatrixA) && !stop) { |
|
|
|
|
|
|
|
|
|
|
|
double[][] matrixA = util.stringToMatrix(stringMatrixA); |
|
|
|
|
|
try { |
|
|
|
|
|
double result = math.calcDeterminat(matrixA); |
|
|
|
|
|
|
|
|
|
|
|
String DisplayableString = Double.toString(result); |
|
|
|
|
|
|
|
|
|
|
|
outputText.setText(DisplayableString); |
|
|
|
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
} catch (IllegalArgumentException e) { |
|
|
|
|
|
|
|
|
|
|
|
outputText.setText(e.getMessage()); |
|
|
|
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
DetBButton.setOnMouseClicked((event) -> { |
|
|
DetBButton.setOnMouseClicked((event) -> { |
|
@ -138,8 +188,6 @@ public class MatrixCalcController { |
|
|
|
|
|
|
|
|
outputText.setText(e.getMessage()); |
|
|
outputText.setText(e.getMessage()); |
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
} |
|
|
if (util.checkInput(stringMatrixB) && !stop) { |
|
|
if (util.checkInput(stringMatrixB) && !stop) { |
|
|
|
|
|
|
|
@ -156,8 +204,6 @@ public class MatrixCalcController { |
|
|
|
|
|
|
|
|
outputText.setText(e.getMessage()); |
|
|
outputText.setText(e.getMessage()); |
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
outputText.setTextAlignment(TextAlignment.CENTER); |
|
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|