[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Exams] [Examples] [Book] [Tutorial] [API]
Back to Exceptions, Continued. On to Arrays and Sequences.
Held Friday, September 17, 1999
Overview
Today, we will return to our project and consider more details about how the individual pieces interact and how we might group them into subprojects. This consideration will also involve some discussion of Java's interfaces.
Notes
lp -pprinter -oduplex
Contents
Handouts
Summary
+----------+
+------| Maildrop |----+ +-------------+
| +----------+ +-+-| Text Client |
+---------+ +---------+ +---------+ | | +-------------+
| Servers |---| Network |---| Mailbox |--+ | |
+---------+ +---------+ +---------+ | | +-----+ |
| +-+-| GUI | |
+-------------+ +---------+ +-----+ +--------+
| MailMessage | | Folders | | \------| Filter |
+-------------+ +---------+ | +--------+
|
+-------------+ +-------+ +---------------+
| MsgInfoList | | Prefs | | Face Database |
+-------------+ +-------+ +---------------+
MailMessage, MsgInfoList, and
Prefs are
utility classes that will be shared by many of the
other classes (or groups of classes).
Mailbox
class. (This is simpler than the one that we'll actually use.)
/**
* A stub for a simple mailbox class.
*
* @author Samuel A. Rebelsky
* @version 1.0 of September 1999
*/
public class Mailbox {
/**
* Activate the mailbox. To force it to throw an InvalidAccount
* exception, use the empty password. To force it to throw a
* ServerError exception, use "root" as the account.
*/
public void login(String account, String password)
throws InvalidAccount, ServerError
{
if (password.equals("")) {
throw new InvalidAccount();
}
if (account.equals("root")) {
throw new ServerError();
}
} // login(String, String)
/**
* Get a list of messages.
*/
public MsgInfoList listMessages() {
MsgInfoList messages = new MessageList();
messages.add("353@alpha.com", "John Smith", "Testing", "1/1/99");
messages.add("354@alpha.com", "Jack Smith", "Testing", "3/1/99");
messages.add("354@beta.com", "Smith", "Testing", "1/1/98");
messages.add("354@gamma.com", "Jack", "More Testing", "1/1/00");
messages.add("000@gamma.com", "Zebra" "Stripes", "5/1/99");
return messages;
} // listMessages()
/**
* Get a message given the message ID. If the message ID starts
* with 0, throws an exceptions.
*/
public MailMessage getMessage(String messageID)
throws MailException
{
if (messageID.charAt(0) == '0') {
throw new MailException("Invalid message ID");
}
return new MailMessage(...);
} // getMessage(String)
} // class Mailbox
Number agree to provide
a set of drawing routines.
Line objects, which
would most likely be a subclass of Polygon (or some
such) would also provide "mathematical" operations (so that you
could add, subtract, and compare lines).
interface instead of class.
implements keyword,
as in
public class Complex
implements Drawable {
// ...
} // Complex
public class Complex
implements Drawable, Number {
// ...
} // Complex
Drawable d = new Complex();
public interface Mailbox {
public void login(String account, String password);
public MsgInfoList listMessages();
public MailMessage getMessage(String messageID);
} // Mailbox()
Tuesday, 10 August 1999
Thursday, 9 September 1999
Thursday, 16 September 1999
Back to Exceptions, Continued. On to Arrays and Sequences.
[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Exams] [Examples] [Book] [Tutorial] [API]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS152/99F/Outlines/outline.14.html
Source text last modified Fri Sep 17 11:17:06 1999.
This page generated on Wed Sep 22 11:16:37 1999 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu