[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Exams] [Examples] [Book] [Tutorial] [API]
Back to Even More Classes and Objects. On to Conditionals.
Held Thursday, September 9, 1999
Overview
Today we will begin to disucss the architecture of our email system. That consideration will lead us to consider three key aspects of object-oriented programming: inheritance, polymorphism, and interfaces.
Notes
Contents
Handouts
Summary
Mailbox class
This discussion of the project was added after class and is based on comments from in class.
Mailbox talks to the mail storage server.
Sender talks to the outgoing mail server.
Folders.
inbox.
trash folder.
Sorter to organize them or a Filter
to select only some,
Composer to compose new messages.
AddressBook class (which may somehow
communicate with the address book on the server).
FaceBook class so that we can display
peoples' pictures when we receive messages from them.
Mailbox class. What methods should that class
provide?
Mailbox. That way,
we get the mailbox for a particular person. We also handle the
question of how to get the password and account to the class.
public Mailbox(String account, String password) { ... }
public MessageInfoList listMessages() { ... }
public MailMessage getMessage(String messageID) { ... }
public void deleteMessage(String messageID) { ... }
public void isValid() { ... }
import MailMessage;
import MessageInfoList;
/**
* A simple implementation of mailboxes (one that doesn't really work).
* Created as an example for CSC152 99F.
*
* @author Samuel A. Rebelsky
* @author The students of CSC152 99F
* @version 1.0 of September 1999
*/
public class Mailbox {
// +--------------+--------------------------------------------
// | Constructors |
// +--------------+
/**
* Create a new mailbox for a particular user. Requires the
* account and password for obvious reasons.
*/
public Mailbox(String account, String password) {
// ...
} // Mailbox(String, String)
// +---------+-------------------------------------------------
// | Methods |
// +---------+
/** List all the messages in the mailbox. */
public MessageInfoList listMessages() {
return new MessageInfoList(); // STUB
} // listMessages()
/** Get one message. */
public MailMessage getMessage(String messageID) {
return new MailMessage(); // STUB
} // getMessage(String)
/** Delete a message. */
public void deleteMessage(String messageID) {
return; // STUB
} // deleteMessage(String)
/** Check if the mailbox is valid. */
public boolean isValid() {
return true; // STUB
} // isValid()
} // class Mailbox
import Mailbox;
import MailMessage;
import MessageInfoList;
import SimpleInput;
import SimpleOutput;
/**
* A simple controlling class to print out the contents of a
* user's mailbox.
*
* @author Samuel A. Rebelsky
* @author The Students of CSC152 99S
* @version 1.0 of September 1999
*/
public class MailDumper {
public static void main(String[] args) {
// Prepare for input and output.
SimpleInput eyes = new SimpleInput();
SimpleOutput pen = new SimpleOutput();
// Other necessary variables.
String account; // The user's account.
String password; // The user's password.
Mailbox mail; // The mailbox we create.
MessageInfoList messages;
// A list of messages in that mailbox.
MailMessage msg; // One mail message.
// 1. Get the account and password. Note that we eventually
// need to update this so that the password is not visible.
pen.print("Account: ");
account = eyes.readString();
pen.print("Password: ");
password = eyes.readString();
// 2. Create the mailbox.
mail = new Mailbox(account, password);
// 3. Ensure that the mailbox was correctly created. If not,
// crash and burn, but in a friendly way.
// ...
// 4. Get the list of messages
// ...
// 5. For each message in that list
// ...
// a. Get the full message
// ...
// b. Print it out
pen.println(msg.toString());
} // main(String[] args)
} // class MailDumper
DrawableObject class
and refine that to particular drawable objects, such as Circle
or Square.
extends keyword.
public class Circle
extends DrawableObject {
...
} // Circle
DrawableObject obj = new Circle();
public void drawWithStrangeColors(DrawableObject obj) {
...
} // drawWithStrangeColors(DrawableObject)
...
drawWithStrangeColors(new Circle());
extends clause,
Java assumes that your object extends java.lang.Object.
FilteredMailbox.
import Mailbox;
/**
* An improved mailbox that knows how to filter messages.
*/
public class FilteredMailbox
extends Mailbox
{
/**
* Build a new filtered mailbox using an account and password.
*/
public FilteredMailbox(String account, String password) {
super(account, password);
} // FilteredMailbox(String, String)
} // class FilteredMailbox
Forthcoming.
Tuesday, 10 August 1999
Wednesday, 8 September 1999
Thursday, 9 September 1999
Back to Even More Classes and Objects. On to Conditionals.
[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.09.html
Source text last modified Thu Sep 9 22:36:59 1999.
This page generated on Tue Sep 21 11:09:51 1999 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu