Skip to content
Snippets Groups Projects
Commit e9bdd4cc authored by thibault.capt's avatar thibault.capt
Browse files

Update mat

parent 468101a5
No related branches found
No related tags found
No related merge requests found
...@@ -90,19 +90,44 @@ public class Equation { ...@@ -90,19 +90,44 @@ public class Equation {
* @param elements les elements * @param elements les elements
* @param line la line en question * @param line la line en question
*/ */
public void createMinEq(String[] elements, int line) { public int createEq(String[] elements, int line) {
try { try {
// vecteur de droite // vecteur de droite
switch(elements[5]) {
case "=": // Si ax=b => ax <= b; ax >= b
// Vecteur de droite
setRightVec(Double.parseDouble(elements[elements.length - 1]));
setRightVec(Double.parseDouble(elements[elements.length - 1])); setRightVec(Double.parseDouble(elements[elements.length - 1]));
// Matrice // Matrice
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
setMat(Double.parseDouble(elements[i]), line, i); setMat(Double.parseDouble(elements[i]), line, i);
setMat(Double.parseDouble(elements[i]), line+1, i);
} }
// On rajoute une ligne
line += 1;
break;
case ">=":
// Vecteur de droite
setRightVec(-Double.parseDouble(elements[elements.length - 1]));
// Matrice
for (int i = 0; i < 5; i++)
setMat(-Double.parseDouble(elements[i]), line, i);
break;
case "<=":
// Vecteur de droite
setRightVec(Double.parseDouble(elements[elements.length - 1]));
// Matrice
for (int i = 0; i < 5; i++)
setMat(Double.parseDouble(elements[i]), line, i);
break;
}
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
return line;
} }
/** /**
......
...@@ -31,7 +31,7 @@ public class Main { ...@@ -31,7 +31,7 @@ public class Main {
String[] elements; String[] elements;
int widthMat = nbLines(sc); int widthMat = nbLines(sc);
sc = new Scanner(f); // remettre le scanner à la première ligne sc = new Scanner(f); // remettre le scanner à la première ligne
Equation eq = new Equation(widthMat); Equation eq = new Equation(widthMat*2); // lignes supp au cas où, il y a des "="
int line = 0; int line = 0;
// Max / Min + function obj // Max / Min + function obj
...@@ -48,7 +48,7 @@ public class Main { ...@@ -48,7 +48,7 @@ public class Main {
case "min": case "min":
case "max": case "max":
// création de l'équation dans le sens min // création de l'équation dans le sens min
eq.createMinEq(elements, line); line = eq.createEq(elements, line);
break; break;
default: default:
System.err.println("Le sens n'a pas été entré."); System.err.println("Le sens n'a pas été entré.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment