1 1 Description of the Program In this assignment, you will write four java files, Message.java, MessageTester.java, Mailbox.java and MailboxTester. java, Stage 1: In the first file Message.java, create a class named Message that models an email message. It should contain the following: • Private instance variables sender, recipient, and messagetext; • A default constructor that takes no inputs (set all members to an empty string); • A constructor takes all three inputs (sender, recipient and messagetext); • Three getter methods to return each of three instance variables (accessor); • Three setter methods to change each of three instance variables (mutator); • A method toString that makes the message into one long string like this: From: Harry Morgan To: Rudolf Reindeer This is my message... Stage 2: In the second file MessageTester.java, write code to test the methods that you write in the class of Message.java. Specifically: 1. Create two message objects using the constructor taking inputs. The inputs are from "messages0.txt’. You can either read the file into message objects, or you can manually initialize the objects using the information from the file. 2. Print them out using toString() method. 3. Set each object using setter methods (Inputs, e.g., CurrentSender1, CurrentRecipient1). 4. Display each object's information using getter methods. Your output should look like Figure 1. 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:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
1
Description of the Program
In this assignment, you will write four java files, Message.java, MessageTester.java,
Mailbox.java and MailboxTester.java,
Stage 1: In the first file Message.java, create a class named Message that models an email
message. It should contain the following:
• Private instance variables sender, recipient, and messagetext;
• A default constructor that takes no inputs (set all members to an empty string);
• A constructor takes all three inputs (sender, recipient and messagetext);
• Three getter methods to return each of three instance variables (accessor);
• Three setter methods to change each of three instance variables (mutator);
A method toString that makes the message into one long string like this:
From: Harry Morgan
To: Rudolf Reindeer
This is my message...
Stage 2: In the second file MessageTester.java, write code to test the methods that you
write in the class of Message.java. Specifically:
1. Create two message objects using the constructor taking inputs. The inputs are from
"messages0.txt". You can either read the file into message objects, or you can
manually initialize the objects using the information from the file.
2. Print them out using toString() method.
3. Set each object using setter methods (Inputs, e.g., CurrentSender1, CurrentRecipient1).
4. Display each object's information using getter methods. Your output should look like
Figure 1.
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
Transcribed Image Text:1 Description of the Program In this assignment, you will write four java files, Message.java, MessageTester.java, Mailbox.java and MailboxTester.java, Stage 1: In the first file Message.java, create a class named Message that models an email message. It should contain the following: • Private instance variables sender, recipient, and messagetext; • A default constructor that takes no inputs (set all members to an empty string); • A constructor takes all three inputs (sender, recipient and messagetext); • Three getter methods to return each of three instance variables (accessor); • Three setter methods to change each of three instance variables (mutator); A method toString that makes the message into one long string like this: From: Harry Morgan To: Rudolf Reindeer This is my message... Stage 2: In the second file MessageTester.java, write code to test the methods that you write in the class of Message.java. Specifically: 1. Create two message objects using the constructor taking inputs. The inputs are from "messages0.txt". You can either read the file into message objects, or you can manually initialize the objects using the information from the file. 2. Print them out using toString() method. 3. Set each object using setter methods (Inputs, e.g., CurrentSender1, CurrentRecipient1). 4. Display each object's information using getter methods. Your output should look like Figure 1. 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
A Blue): Terminal Window - 1_Solution
Options
After creating message objects:
From: OriginalSender1
To: OriginalRecipient1
This is my original message1
From: OriginalSender2
To: OriginalRecipient2
This is my original message2
After using setter and getter methods:
Sender: CurrentSender1
Recipient: CurrentRecipient1
Message text: This is my current message1
Sender: CurrentSender2
Recipient: CurrentRecipient2
Message text: This is my current message2
Can only enter input while your programming is running
Figure 1: A screenshot of the program output 1.
• Private instance variables messages and num0fMessages
Hint: the type for messages should be ArrayList<Message>
• 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 įth message from the list
• public int getNumber0fMessages ()
Return the number of messsages in mailbox
• public void removeMessage (int i)
Remove the į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.
Transcribed Image Text:A Blue): Terminal Window - 1_Solution Options After creating message objects: From: OriginalSender1 To: OriginalRecipient1 This is my original message1 From: OriginalSender2 To: OriginalRecipient2 This is my original message2 After using setter and getter methods: Sender: CurrentSender1 Recipient: CurrentRecipient1 Message text: This is my current message1 Sender: CurrentSender2 Recipient: CurrentRecipient2 Message text: This is my current message2 Can only enter input while your programming is running Figure 1: A screenshot of the program output 1. • Private instance variables messages and num0fMessages Hint: the type for messages should be ArrayList<Message> • 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 įth message from the list • public int getNumber0fMessages () Return the number of messsages in mailbox • public void removeMessage (int i) Remove the į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.
Expert Solution
Step 1

The answer is given below:-

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education