Skip to content

Commit

Permalink
🐛 resolve bug when user try do calculate 2x2 linear system with z unk…
Browse files Browse the repository at this point in the history
…nown
  • Loading branch information
Brendon3578 committed May 7, 2024
1 parent 07c5d59 commit bad23e9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function solveSystem() {

showStatusMessage("success", equationResultOutput.message);
} catch (e) {
console.error(e.message);
console.error(e);
showStatusMessage(
"error",
e.message || "Não foi possível realizar o cálculo."
Expand Down Expand Up @@ -449,6 +449,11 @@ function extractCoefficients(eq, elementToFocusIfError) {
// Verifica se a equação contém a incógnita z
const is3x3 = /z/i.test(eq);

if (is3x3 && is3x3LinearSystem == false)
throw new Error(
"Você está tentando calcular um sistema 3x3 com apenas duas equações!"
);

// Define padrão de correspondência com base no número de incógnitas
const pattern = is3x3
? /(-?\d*)[xX]\s*([+-])?\s*(\d*)[yY]?\s*([+-])?\s*(\d*)[zZ]?\s*=\s*(-?\d*)/
Expand Down

0 comments on commit bad23e9

Please sign in to comment.