In java, implement a simple email messaging system. a message has a recipient, a sender, and a message text. a mailbox can store messages. supply a number of mailboxes for different users and a user interface for the user to login, send messages to other users, read their own messages, and log out. Given the code I have so far, what needs to be added? class Message { private String sender; private String recipient; private String messageText; public Message(String sender, String recipient) { this.sender = sender; this.recipient = recipient; this.messageText = " "; } public void append(String text) { this.messageText += text; } public String toString() { return "From: " + sender + " To: " + recipient + "\n" + this.messageText; } } class Mailbox { private ArrayList email; public Mailbox() { this.email = new ArrayList(); } public Message getMessage(int i) { return this.email.get(i); } public void addMessage(Message m) { this.email.add(m); } public void removeMessage(int i) { this.email.remove(i); } public int mailBoxSize() { return this.email.size(); } }
In java, implement a simple email messaging system. a message has a recipient, a sender, and a message text. a mailbox can store messages. supply a number of mailboxes for different users and a user interface for the user to login, send messages to other users, read their own messages, and log out.
Given the code I have so far, what needs to be added?
class Message {
private String sender;
private String recipient;
private String messageText;
public Message(String sender, String recipient) {
this.sender = sender;
this.recipient = recipient;
this.messageText = " ";
}
public void append(String text) {
this.messageText += text;
}
public String toString() {
return "From: " + sender + " To: " + recipient + "\n" + this.messageText;
}
}
class Mailbox {
private ArrayList<Message> email;
public Mailbox() {
this.email = new ArrayList<Message>();
}
public Message getMessage(int i) {
return this.email.get(i);
}
public void addMessage(Message m) {
this.email.add(m);
}
public void removeMessage(int i) {
this.email.remove(i);
}
public int mailBoxSize() {
return this.email.size();
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps