import java.io.*;
public class  CourseAnnouncementApplication {
	// A course announcement application. 
	// Maintain a list of course announcements, adding
	// new announcements obtained from the console.
	// When the user enters quit as the date, we expire announcements
	// 2 and 4 and then print out the list (in reverse order).

	public static void main(String [] args) throws IOException {
		CourseAnnouncementList cal=new CourseAnnouncementList();

		BufferedReader br=new BufferedReader(
			new InputStreamReader(System.in)
		);

		// Repeatedly get announcements from the console
		// and add them to cal
		while(true){
			System.out.print("Announcement date: ");
			String date=br.readLine();
			if(date.equals("quit"))break;
			System.out.print("Announcement message: ");
			String message=br.readLine();
			CourseAnnouncement ca=new CourseAnnouncement(date, message);
			cal.add(ca);
		}
		cal.expire(2);
		cal.expire(4);
		cal.print();
	}
}

