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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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. 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY