Using JAVA Part A) 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: 1) A constructor that takes the sender and recipient. 2) 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: “From: Harry Morgan%nTo: Rudolf Reindee%n . . . “ Write a program that uses this class to make a message and print it. Part B) Design a class Mailbox that stores e-mail messages, using the Message class in part a) Implement the following methods in the Message class. public void addMessage(Message m) // Adds Message M to the Mailbox public Message getMessage(int i) // returns the ith message from the Mailbox public void removeMessage(int i) // removes the ith message from the Mailbox public int mailBoxSize () // returns the number of messages in the Mailbox Write a program to demonstrate the functionality of the Mailbox. Add messages to the Mailbox, print messages from the Mailbox, then remove a message form the Mailbox.
Using JAVA
Part A) 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:
1) A constructor that takes the sender and recipient.
2) 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: “From: Harry Morgan%nTo: Rudolf Reindee%n . . . “
Write a program that uses this class to make a message and print it.
Part B) Design a class Mailbox that stores e-mail messages, using the Message class in part a) Implement the following methods in the Message class.
- public void addMessage(Message m) // Adds Message M to the Mailbox
- public Message getMessage(int i) // returns the ith message from the Mailbox
- public void removeMessage(int i) // removes the ith message from the Mailbox
- public int mailBoxSize () // returns the number of messages in the Mailbox
Write a program to demonstrate the functionality of the Mailbox. Add messages to the Mailbox, print messages from the Mailbox, then remove a message form the Mailbox.
![](/static/compass_v2/shared-icons/check-mark.png)
The JAVA code is given below with output screenshot
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
I am recieving error "void cannot be dereferenced" and therefore "cannot envoke toString()"
How would one fix this?
System.out.println(mailbox.getMessage(0).toString());
System.out.println(mailbox.getMessage(1).toString());
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)