diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF deleted file mode 100644 index 5ee19cb097ba1bb5961c11d204d1c4a34f14da5f..0000000000000000000000000000000000000000 --- a/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: Main - diff --git a/src/Equation.java b/src/Equation.java index 21c6e03f6b6a72e448fe463142f0b34d9d9addea..3101072b5fc6123bca3d04ccd75020a7567dea83 100644 --- a/src/Equation.java +++ b/src/Equation.java @@ -49,10 +49,6 @@ public class Equation { this.rightVec.add(d); } - public Double[][] getMat() { - return mat; - } - public Double getMatAtId(int w, int h) { return mat[w][h]; } @@ -70,13 +66,19 @@ public class Equation { /** * Récupérer les information de la première ligne (sens + fonction obj) - * @param elements + * @param elements inéquation */ public void setFirstLine(String[] elements) { try { setSens(elements[0]); - for (int i = 1; i < elements.length; i++){ - setFuncObj(Double.parseDouble(elements[i])); + if(getSens().equals("min")) { + for (int i = 1; i < elements.length; i++) { + setFuncObj(Double.parseDouble(elements[i])); + } + } else { + for (int i = 1; i < elements.length; i++) { + setFuncObj(-Double.parseDouble(elements[i])); + } } } catch (NumberFormatException ex) { ex.printStackTrace(); @@ -85,8 +87,8 @@ public class Equation { /** * Créer le vecteurs éléments de droite et la matrice Amxn quand le sens est à min - * @param elements - * @param line + * @param elements les elements + * @param line la line en question */ public void createMinEq(String[] elements, int line) { try { @@ -103,62 +105,6 @@ public class Equation { } } - /** - * Créer le vecteurs éléments de droite et la matrice Amxn quand le sens est à max - * @param elements - * @param line - */ - public int createMaxEq(String[] elements, int line) { - try { - // 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])); - - // Matrice - for (int i = 0; i < 5; 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) { - ex.printStackTrace(); - } - return line; - } - - /** - * Ajouter dans le vecteur de droite - * @param elements - */ - public void addInRightVec(String[] elements){ - - } - /** * Print les vecteurs et la matrice */ diff --git a/src/Main.java b/src/Main.java index 66d107a5adcdfa79b6e827c4832876d7cfd36f24..53a2b42458e3ddbdcfc326093dab1783578b8279 100644 --- a/src/Main.java +++ b/src/Main.java @@ -20,7 +20,7 @@ public class Main { /** * Fonction main - * @param args + * @param args arguements en entrées */ public static void main(String[] args) { try { @@ -29,7 +29,7 @@ public class Main { String[] elements; int widthMat = nbLines(sc); sc = new Scanner(f); // remettre le scanner à la première ligne - Equation eq = new Equation(widthMat*2); // ajout de ligne supp si sens: max et = donc + 1 ligne + Equation eq = new Equation(widthMat); int line = 0; // Max / Min + function obj @@ -41,16 +41,13 @@ public class Main { while (sc.hasNextLine()) { String tmp = sc.nextLine(); elements = tmp.split(";"); - + switch(eq.getSens()) { - case "min": + case "min": + case "max": // création de l'équation dans le sens min eq.createMinEq(elements, line); break; - case "max": - // création de l'équation dans le sens max (rajout de line si besoin dans la matrice) - line = eq.createMaxEq(elements, line); - break; default: System.err.println("Le sens n'a pas été entré."); System.exit(1); diff --git a/src/input.txt b/src/input.txt index a4edd0fe637216e5ed11fdb94f0015bba40239d0..13905c60fd0330f4a17676a0313e0b6555997d00 100644 --- a/src/input.txt +++ b/src/input.txt @@ -1,4 +1,4 @@ -min;8;7.5;12;5;9; +max;8;7.5;12;5;9; 3.5;4;6;3;9;<=;22.6; 5;2;8;1;2.5;>=;3; 0;1;0;1;0;=;1;