import java.io.*;

public class UseQueue {
	public static void main(String[] args) throws IOException {
		Queue q = new CircularQueue(4);
		
		BufferedReader br = new BufferedReader(
					new FileReader("names"));
		getEntries(q, br);
	}
	
	public static void getEntries(Queue q, BufferedReader in) {
		try {
			String s = in.readLine();
			while(!s.equals("done")) {
				try {
					q.enqueue(s);
					
				} catch (QueueFullException qfe) {
					System.out.println(qfe.getMessage());
					qfe.printStackTrace();
					System.out.println("Queue is full");
					return;
				}
				s = in.readLine();
			}
		} catch (EOFException e) {
			System.out.println("Reached the end of the file");
		} catch (IOException e) {
			System.out.println("Problems reading input!");
		}
	}
}