Question: Design a class Mailbox that stores e-mail messages, using the Message class of Exercise P8.15. Implement the following methods: public void addMessage(Message m)
Design a class Mailbox that stores e-mail messages, using the Message class of Exercise P8.15. Implement the following methods:
• public void addMessage(Message m)
• public Message getMessage(int i)
• public void removeMessage(int i)
Data from Exercise P8.15.
Design a class Message that models an e-mail message. A message has a recipient, a sender, and a message text. Support the following methods:
• A constructor that takes the sender and recipient
• A method append that appends a line of text to the message body
• A method toString that makes the message into one long string like this: "From:
Harry Morgan%nTo: Rudolf Reindeer%n . . ." Write a program that uses this class to make a message and print it.
Step by Step Solution
3.44 Rating (160 Votes )
There are 3 Steps involved in it
ANSWER PART A import javautil public class Mailbox ArrayList messages new ArrayList public void addM... View full answer
Get step-by-step solutions from verified subject matter experts
