// Allison Obourn // CSE 143, Autumn 2015 // This program hires and fires teaching assistants based on their experience. // It demonstrates the use of the PriorityQueue data structure. import java.io.*; import java.util.*; public class TAManager { public static void main(String[] args) throws FileNotFoundException { // read all current TAs from a file "tas.txt" Scanner taFile = new Scanner(new File("tas.txt")); Queue tas = new PriorityQueue(); while(taFile.hasNext()) { String name = taFile.next(); int exp = taFile.nextInt(); TeachingAssistant ta = new TeachingAssistant(name, exp); tas.add(ta); } System.out.println(tas); // FIRE all TAs with <= 2 quarters of experience while(!tas.isEmpty() && tas.peek().getExperience() < 3) { tas.remove(); } // print all TAs in increasing order of experience while(!tas.isEmpty()) { System.out.println(tas.remove()); } } }