public static void main(String[] args) { try { AssociativeArray<Integer> ent = new AssociativeArray(20); p101queue<String> ref = new p101queue(); File food = new File(args[0]); Scanner readf = new Scanner(food); while (readf.hasNextLine()) { String line = readf.nextLine(); if (line.split(":")[0].equals("entrada")) { if (ent.exists(line.split(" ")[1])) ent.set(line.split(" ")[1], (Integer) ((int) (ent.get(line.split(" ")[1]) + 1))); else ent.set(line.split(" ")[1], 1); } else { ref.in(line.substring(7)); } while (!ref.isEmpty()) { if (checkCanRemove(ref.peek(), ent)) { out.println("Refeição servida: " + ref.peek()); ref.out(); } else break; } } out.println("Comida em Stock:"); for (String i : ent.keysToArray()) out.println("\t" + i + " : " + ent.get(i)); while (!ref.isEmpty()) { out.println("Refeições não servidas: " + ref.peek()); ref.out(); } } catch (Throwable e) { err.println("Erro nos ficheiros.\n" + e.getMessage()); } }