first commit

This commit is contained in:
Boris
2024-01-15 20:14:10 +00:00
commit 8c81ee28b7
3106 changed files with 474415 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
/**
* A class to model a simple email client. The client is run by a
* particular user, and sends and retrieves mail via a particular server.
*
* @author David J. Barnes and Michael Kölling
* @version 2016.02.29
*/
public class MailClient
{
// The server used for sending and receiving.
private MailServer server;
// The user running this client.
private String user;
/**
* Create a mail client run by user and attached to the given server.
*/
public MailClient(MailServer server, String user)
{
this.server = server;
this.user = user;
}
/**
* Return the next mail item (if any) for this user.
*/
public MailItem getNextMailItem()
{
return server.getNextMailItem(user);
}
/**
* Print the next mail item (if any) for this user to the text
* terminal.
*/
public void printNextMailItem()
{
MailItem item = server.getNextMailItem(user);
if(item == null) {
System.out.println("No new mail.");
}
else {
item.print();
}
}
/**
* Send the given message to the given recipient via
* the attached mail server.
* @param to The intended recipient.
* @param message The text of the message to be sent.
*/
public void sendMailItem(String to, String message)
{
MailItem item = new MailItem(user, to, message);
server.post(item);
}
}