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

Update

parent b543c13a
No related branches found
No related tags found
No related merge requests found
.idea/*
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/tp-math.iml" filepath="$PROJECT_DIR$/.idea/tp-math.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
math.iml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
import java.util.ArrayList;
public class Equation {
private String _sens;
private String _funcObj;
private final ArrayList<String> _sc;
public String getSens() {
return _sens;
}
public void setSens(String _sens) {
this._sens = _sens;
}
public String getFuncObj() {
return _funcObj;
}
public void setFuncObj(String funcObj) {
this._funcObj = funcObj;
}
public ArrayList<String> getSc() {
return _sc;
}
public void setSc(String s) {
this._sc.add(s);
}
public Equation() {
setSens(null);
setFuncObj(null);
this._sc = new ArrayList<>();
}
public void printEq() {
System.out.println("Sens: " + getSens());
System.out.println("Fonction objective: " + getFuncObj());
System.out.println("S.C.:");
for (String s: getSc()) {
System.out.println(s);
}
}
}
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Main {
private static void getFirstLine(Equation eq, String[] elements) {
// Première ligne différente
eq.setSens(elements[0]);
StringBuilder funcObj = new StringBuilder();
for (int i = 1; i < elements.length; i++)
if(i == elements.length - 1)
funcObj.append(elements[i]);
else
funcObj.append(elements[i]).append(", ");
eq.setFuncObj(String.valueOf(funcObj));
}
private static void newSC(Equation eq, String[] elements) {
StringBuilder str = new StringBuilder();
for (int i = 0; i < elements.length; i++ ) {
if(i == elements.length - 1)
str.append(elements[i]);
else
str.append(elements[i]).append(", ");
}
eq.setSc(String.valueOf(str));
}
public static void main(String[] args) {
try {
File f = new File("src/input.txt");
Scanner sc = new Scanner(f);
String[] elements;
Equation eq = new Equation();
// Première ligne différente
String firstLine = sc.nextLine();
elements = firstLine.split(";");
getFirstLine(eq, elements);
// Le reste
while (sc.hasNextLine()) {
String tmp = sc.nextLine();
elements = tmp.split(";");
newSC(eq, elements);
}
eq.printEq();
sc.close();
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
}
min;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;
5;0.5;2;6;2;<=;104.3;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment