2. Read all eight messages into Mailbox object from the file of "messages1.txt". The values for each line will be used to initialize each instance variable of the Message object, and then added into the Mailbox object. Important: Your must read the values in from the file using Scanner object, you are not allowed to initialize the objects manually. 3. Print out all messages using printAllMessages () method. Your output should look like Figure 2. Bluel: Terminal Window - 1 Solution Options Message list in the mailbox after loading from a file Message 1 From: Eric_A_Bially To: Zachary_B_Howard This is_test_message_1 Message 2 From: Brett_V_Bohorquez To: Marcus_R_McPartland This is_test_message_2 Message 3 From: Aron_I_Brewster To: Patrick_C_Nauman This is_test_message_3 Message 4 From: Joshua_J_Dennis To: Jacob_G_Neff This_is_test_message_4 Message 5 From: Stephen_M_Gentzler To: Kevin_A_0rlowski This is_test_message_5 Message 6 From: Adam_James_D_Geosits To: Oscar_J_Phillips This is_test_message_6 Message 7 From: Rudolf_C_Gouker To: Andy_R_Sayer This_is_test_message_7 Message 8 From: Zachary_B_Howard To: Craig_Smith This is_test_message_8 Figure 2: A screenshot of the program output 2. 4. Remove message at position 0 (index) using removeMessage (), and repeat it six times.
![5. Print out all messages in the mailbox object using printAllMessages () method. Your
output should look like Figure 3.
4 Bluel: Terminal Window - 1_Solution
Options
Message list in the mailbox after removing six messages
Message 1
From: Rudolf_C_Gouker
To: Andy_R_Sayer
This is test_message_7
Message 2
From: Zachary_B_Howard
To: Craig Smith
This is test_message_8
Can only enter input while your programming is running
Figure 3: A screenshot of the program output 3.
2
Required outputs
You should print out all three outputs as shown in Figures 1-3. Put them together (copy
and paste) in one output file (.txt).
3
Submission
Upload the following items on D2L dropbox, including:
1. The source code, including four java files:
(a) Message.java
(b) MessageTester.java
(c) Mailbox.java and
(d) MailboxTester.java
2. One program output file (containing the information similar to three figures).](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb8104f98-69e5-481c-8cf6-56c2b6c36b3a%2F6b4a7e75-a826-46d6-9ed3-5ec04f5ad1ae%2Fpcd1av_processed.png&w=3840&q=75)
![2. Read all eight messages into Mailbox object from the file of "messages1.txt". The
values for each line will be used to initialize each instance variable of the Message
object, and then added into the Mailbox object.
Important: Your must read the values in from the file using Scanner object, you
are not allowed to initialize the objects manually.
3. Print out all messages using printAllMessages () method. Your output should look
like Figure 2.
Bluel: Terminal Window - 1 Solution
Options
Message list in the mailbox after loading from a file
Message 1
From: Eric_A_Bially
To: Zachary_B_Howard
This is_test_message_1
Message 2
From: Brett_V_Bohorquez
To: Marcus_R_McPartland
This is_test_message_2
Message 3
From: Aron_I_Brewster
To: Patrick_C_Nauman
This is_test_message_3
Message 4
From: Joshua_J_Dennis
To: Jacob_G_Neff
This_is_test_message_4
Message 5
From: Stephen_M_Gentzler
To: Kevin_A_0rlowski
This is_test_message_5
Message 6
From: Adam_James_D_Geosits
To: Oscar_J_Phillips
This is_test_message_6
Message 7
From: Rudolf_C_Gouker
To: Andy_R_Sayer
This_is_test_message_7
Message 8
From: Zachary_B_Howard
To: Craig_Smith
This is_test_message_8
Figure 2: A screenshot of the program output 2.
4. Remove message at position 0 (index) using removeMessage (), and repeat it six times.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb8104f98-69e5-481c-8cf6-56c2b6c36b3a%2F6b4a7e75-a826-46d6-9ed3-5ec04f5ad1ae%2Fvk8ce16_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Hi... Please check below java code.
Mailbox.java
import java.util.List;
public class Mailbox {
private List<Message> all;
private int numOfMessages;
public List<Message> getAll() {
return all;
}
public void setAll(List<Message> all) {
this.all = all;
}
public int getNumOfMessages() {
return numOfMessages;
}
public void setNumOfMessages(int numOfMessages) {
this.numOfMessages = numOfMessages;
}
public Mailbox(List<Message> all, int numOfMessages) {
super();
this.all = all;
this.numOfMessages = numOfMessages;
}
public Message getMessage(int i){
return all.get(i-1);
}
public void removeMessages(int i){
all.remove(i-1);
}
public void printAllMessages(){
for(Message m:all){
System.out.println(m.getMessage());
}
}
}
Message.java
public class Message {
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Message(String message) {
super();
this.message = message;
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)