Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class ProcesKwestieRegister {
- private ArrayList<ProcesKwestie> register;
- public ProcesKwestieRegister(File f){
- register = new ArrayList<>();
- int aantalIngeladen = leesProcesKwesties(f);
- System.out.println(aantalIngeladen + " proces kwesties ingeladen!");
- }
- public int leesProcesKwesties(File f){
- Scanner inputStream = null;
- try
- {
- inputStream = new Scanner(f);
- }
- catch(FileNotFoundException e)
- {
- System.out.println("Het bestand kan niet ingelezen worden!");
- return 0;
- }
- int counter = 0;
- while(inputStream.hasNextLine()){
- String line = inputStream.nextLine(); //als het eerste element er is, weet je direct dat de rest er ook sowieso is : 7 in totaal
- line += inputStream.nextLine();
- line += inputStream.nextLine();
- line += inputStream.nextLine();
- line += inputStream.nextLine();
- line += inputStream.nextLine();
- line += inputStream.nextLine();
- ProcesKwestie kwestie = ProcesKwestie.parse(line);
- register.add(kwestie);
- counter++;
- }
- return counter;
- }
- public void setPrioriteitenProces(String procesID){
- ArrayList<ProcesKwestie> kwesties = new ArrayList<>();
- for(ProcesKwestie nextKwestie : register)
- {
- if(procesID.equals(nextKwestie.getProces())) //er zijn meerdere Proceskwesties met dezelfde procesID
- {
- kwesties.add(nextKwestie);
- }
- }
- if(kwesties.isEmpty()){
- throw new IllegalArgumentException("Er zijn geen proces kwesties voor " + procesID +"!"); //bij het oproepen van deze methode kan het exception gooien -> bij oproep try-catch toepassen
- }
- ProcesKwestie[] arrayKwesties = new ProcesKwestie[kwesties.size()];
- kwesties.toArray(arrayKwesties);
- ArrayList<IKwestie> arrayListKwesties = ParetoAnalyse.paretoAnalyse(arrayKwesties);
- for( int i = 0 ; i < arrayListKwesties.size() ; i++) {
- arrayListKwesties.get(i).setPrioriteit(i+1);
- }
- for(IKwestie nextKwestie : kwesties)
- {
- if(!arrayListKwesties.contains(nextKwestie)) {
- nextKwestie.setPrioriteit(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement