import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class SoknadsBehandler implements Runnable{ private String filString; private Monitor monitor; public SoknadsBehandler(String filString, Monitor monitor){ this.filString = filString; this.monitor = monitor; } @Override public void run(){ Scanner sc = null; try { sc = new Scanner(new File(filString)); } catch (FileNotFoundException e) { System.out.println("Fant ikke filen " + filString); return; } while(sc.hasNext()){ String[] delt = sc.nextLine().trim().split(" "); String navn = delt[0]; int alder = Integer.parseInt(delt[2]); int prio = 0; if(alder < 30) prio += 2; if(alder < 35) prio += 2; if(delt[1].equals("ja")) prio += 3; if(delt[3].equals("ja")) prio += 2; monitor.leggTil(new Soknad(navn, prio)); try { Thread.sleep(10000); } catch (Exception e) {} } monitor.leggTil(null); } }