Stage 3: In the third file Mailbox.java, create a class named Mailbox that models a mailbox that contains a list of email messages. It should contain the following: 1 Figure 1: A screenshot of the program output 1. • Private instance variables messages and numOfMessages Hint: the type for messages should be ArrayList • public Mailbox() A default constructor to initialize two instance variables • public void addMessage(Message m) Add a new message into the list messages, and update the numOfMessages • public Message getMessage(int i) Return the i th message from the list • public int getNumberOfMessages() Return the number of messsages in mailbox • public void removeMessage(int i) Remove the i th message from the list • public void printAllMessages() Print out all messages in the mailbox Stage 4: In the fourth file MailboxTester.java, you will need to do the followings: 1. Create an object of Mailbox type. 2 2. Read all eight messages into Mailbox objec
Stage 3: In the third file Mailbox.java, create a class named Mailbox that models a mailbox that contains a list of email messages. It should contain the following: 1 Figure 1: A screenshot of the program output 1. • Private instance variables messages and numOfMessages Hint: the type for messages should be ArrayList • public Mailbox() A default constructor to initialize two instance variables • public void addMessage(Message m) Add a new message into the list messages, and update the numOfMessages • public Message getMessage(int i) Return the i th message from the list • public int getNumberOfMessages() Return the number of messsages in mailbox • public void removeMessage(int i) Remove the i th message from the list • public void printAllMessages() Print out all messages in the mailbox Stage 4: In the fourth file MailboxTester.java, you will need to do the followings: 1. Create an object of Mailbox type. 2 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. Figure 2: A screenshot of the program output 2. 4. Remove message at position 0 (index) using removeMessage(), and repeat it six times. 3 5. Print out all messages in the mailbox object using printAllMessages() method. Your output should look like Figure 3. Figure 3: A screenshot of the program output 3.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 1 images
![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)