lecture fichier instance complétée
This commit is contained in:
parent
9a21011ffb
commit
568f35d8e5
2 changed files with 55 additions and 0 deletions
55
tp/code/ProductionHoraire.java
Normal file
55
tp/code/ProductionHoraire.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
import java.nio.file.*;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class ProductionHoraire {
|
||||
public static void main(String[] args) {
|
||||
// lecture des lignes du fichier d'instance
|
||||
String instancePath = args[0];
|
||||
String[] variablesInstance = null;
|
||||
String[] strLigne2 = null;
|
||||
String[] strLigne3 = null;
|
||||
try {
|
||||
List<String> lignesInstance = Files.readAllLines(Paths.get(instancePath));
|
||||
variablesInstance = lignesInstance.get(0).split("\\s+");
|
||||
strLigne2 = lignesInstance.get(1).split("\\s+");
|
||||
strLigne3 = lignesInstance.get(2).split("\\s+");
|
||||
}
|
||||
catch (IOException e){
|
||||
System.err.println("Caught IOException: " + e.getMessage());
|
||||
}
|
||||
catch (Exception e){
|
||||
System.err.println("Caught Exception: " + e.getMessage());
|
||||
}
|
||||
// traitement de la 1re ligne
|
||||
|
||||
Integer N = Integer.valueOf(variablesInstance[0]);
|
||||
Integer MIN_H = Integer.valueOf(variablesInstance[1]);
|
||||
Integer MAX_H = Integer.valueOf(variablesInstance[2]);
|
||||
Integer MIN_PERIODE = Integer.valueOf(variablesInstance[3]);
|
||||
// traitement de la 2e ligne
|
||||
List<Integer> nbEmployesRequis = new ArrayList<>();
|
||||
|
||||
for (String s: strLigne2) {
|
||||
Integer i = Integer.valueOf(s);
|
||||
nbEmployesRequis.add(i);
|
||||
}
|
||||
// traitement de la 3e ligne
|
||||
List<Integer> nbEmployesSouhaite = new ArrayList<>();
|
||||
|
||||
for (String s: strLigne3) {
|
||||
Integer i = Integer.valueOf(s);
|
||||
nbEmployesRequis.add(i);
|
||||
}
|
||||
|
||||
// Vérification du fichier d'instance
|
||||
System.out.println("### Debut Validation Lecture Instance ###");
|
||||
System.out.println("N="+N.toString());
|
||||
System.out.println("MIN_H="+MIN_H.toString());
|
||||
System.out.println("MAX_H="+MAX_H.toString());
|
||||
System.out.println("MIN_PERIODE="+MIN_PERIODE.toString());
|
||||
System.out.println("nbEmployesRequis="+nbEmployesRequis.toString());
|
||||
System.out.println("nbEmployesSouhaite="+nbEmployesRequis.toString());
|
||||
System.out.println("### Fin Validation Lecture Instance ###");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue