im doing homework but im stuck in some doubts, my homework is about creating a mail account that sends and receives mail, but now I want to list only messages that were enchanged by users with a specified subject. im using lists and maps, and my idea is to create a tree Map that stores every message but I want to iterate them only by specified subject. example:
SUBJECT(command in main that searches for messages with a specific subject)
hello(subject user wants to find)
date | subject | email | text
2012-01-31 | hello | amigo@ptmail.com | everthings cool?
2012-01-29 | hello | outroamigo@ptmail.com | yes indeed.
//my construtor
public class MailClass implements Mail {
private List<Email> emails;
private List<Message> received;
private List<Message> sent;
private Map<String,Message> allMessages;
public CorreioClass()
{
emails = new LinkedList<Email>();
recebidas = new LinkedList<Mail>();
enviadas=new LinkedList<Mail>();
allMessages=new TreeMap<>();
}
public void send(String subject, String email, String text, String date) throws DuplicadoException
{
if ( RepeteadedMessageSent(subject, email, date))
{
throw new DuplicadoException();
} else
{
Message msgSend = new MessageClass(subject, email, text, date);
sent.add(msgSend);
allMessages.put(subject, msgSend);
}
}