public class Main
1:
2: package mail;
3:
4: import java.util.*;
5:
6: public class Main {
7:
8: static Mail[] se450 = {
9: new Mail("Bill Gates", "Need extension for final project",
10: getTime(2001, Calendar.NOVEMBER, 20, 23, 50),
11: MailPriority.VERY_HIGH, MailStatus.REPLIED),
12: new Mail("Linus Torvalds", "Final project: Linux -- a small OS",
13: getTime(2001, Calendar.NOVEMBER, 19, 23, 39),
14: MailPriority.VERY_HIGH, MailStatus.REPLIED),
15: new Mail("John Valissides", "Question on Facade pattern",
16: getTime(2001, Calendar.NOVEMBER, 18, 14, 56),
17: MailPriority.VERY_HIGH, MailStatus.REPLIED),
18: };
19:
20: static Mail[] se452 = {
21: new Mail("Marc Andreesen", "Problem with Netscape 7.02",
22: getTime(2001, Calendar.OCTOBER, 9, 23, 30),
23: MailPriority.HIGH, MailStatus.NEW),
24: new Mail("James Gosling", "HW4 submission, version 3.14159",
25: getTime(2001, Calendar.OCTOBER, 2, 22, 40),
26: MailPriority.HIGH, MailStatus.NEW),
27: };
28:
29: static Mail[] work = {
30: new Mail("Ralph Johnson", "CFP: PLOP",
31: getTime(2001, Calendar.NOVEMBER, 16, 20, 10),
32: MailPriority.HIGH, MailStatus.NEW),
33: new Mail("Chris Galvin", "Your proposal",
34: getTime(2001, Calendar.OCTOBER, 24, 4, 21),
35: MailPriority.HIGH, MailStatus.NEW),
36: new Mail("David Boise", "Abstract of my talk",
37: getTime(2001, Calendar.DECEMBER, 2, 9, 24),
38: MailPriority.HIGH, MailStatus.NEW),
39: };
40:
41: static Mail[] news = {
42: new Mail("WSJ.com", "Yahoo files for bankruptcy",
43: getTime(2002, Calendar.JULY, 6, 7, 00),
44: MailPriority.HIGH, MailStatus.NEW),
45: new Mail("CERT", "Security alert, Windows XXP-3",
46: getTime(2003, Calendar.JANUARY, 1, 0, 00),
47: MailPriority.VERY_HIGH, MailStatus.NEW),
48: new Mail("Scott McNealy", "Top 10 reasons for breaking up Microsoft",
49: getTime(2001, Calendar.SEPTEMBER, 21, 9, 30),
50: MailPriority.MEDIUM, MailStatus.READ),
51: new Mail("Gordon Moore", "10 myths of Moors's law",
52: getTime(2001, Calendar.SEPTEMBER, 11, 6, 23),
53: MailPriority.MEDIUM, MailStatus.READ),
54: };
55:
56: static Mail[] junks = {
57: new Mail("William Gates, III", ".NET Framework",
58: getTime(2001, Calendar.OCTOBER, 26, 22, 12),
59: MailPriority.HIGH, MailStatus.NEW),
60: new Mail("AOL", "Free unlimited DSL with ...",
61: getTime(2001, Calendar.OCTOBER, 2, 23, 59),
62: MailPriority.HIGH, MailStatus.NEW),
63: };
64:
65: public static MailFolder buildInbox() {
66: MailFolder inboxFolder = new MailFolder("Inbox");
67: MailFolder coursesFolder = new MailFolder("Courses");
68: MailFolder se450Folder = new MailFolder("SE450");
69: se450Folder.add(se450);
70: MailFolder se452Folder = new MailFolder("SE452");
71: se452Folder.add(se452);
72: coursesFolder.add(se450Folder);
73: coursesFolder.add(se452Folder);
74: MailFolder workFolder = new MailFolder("Work");
75: workFolder.add(work);
76: MailFolder newsFolder = new MailFolder("News");
77: newsFolder.add(news);
78: MailFolder junksFolder = new MailFolder("Junk Mails");
79: junksFolder.add(junks);
80: inboxFolder.add(coursesFolder);
81: inboxFolder.add(workFolder);
82: inboxFolder.add(newsFolder);
83: inboxFolder.add(junksFolder);
84: return inboxFolder;
85: }
86:
87: public static void main(String[] args) {
88: MailFolder inboxFolder = buildInbox();
89: System.out.println("You " + inboxFolder.count() + " mails in Inbox");
90: System.out.println("You " + inboxFolder.countNewMail() + " new mails in Inbox");
91: }
92:
93: protected static Date getTime(int year, int month, int date, int hour, int minute) {
94: Calendar calendar = Calendar.getInstance();
95: calendar.set(year, month, date, hour, minute, 0);
96: return calendar.getTime();
97: }
98:
99: }