1 Description of the Program In this assignment, you will write four java files, Message.java, MessageTester.java,...
Fantastic news! We've Found the answer you've been seeking!
Question:
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., Current Sender1, 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: BlueJ: Terminal Window- 1 Solution Options After creating message objects: From: Original Sender 1 To: OriginalRecipient1 This is my original message1 From: OriginalSender2 To: OriginalRecipient2 This is my original message2 After using setter and getter methods: Sender: Current Sender1 Recipient: CurrentRecipient1 Message text: This is my current message1 Sender: Current Sender2 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 numOfMessages 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 ith message from the list • public int getNumberOfMessages () Return the number of messsages in mailbox • public void removeMessage (int i) Remove the ith 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. 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_Orlowski 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 print AllMessages () method. Your output should look like Figure 3. 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). 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., Current Sender1, 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: BlueJ: Terminal Window- 1 Solution Options After creating message objects: From: Original Sender 1 To: OriginalRecipient1 This is my original message1 From: OriginalSender2 To: OriginalRecipient2 This is my original message2 After using setter and getter methods: Sender: Current Sender1 Recipient: CurrentRecipient1 Message text: This is my current message1 Sender: Current Sender2 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 numOfMessages 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 ith message from the list • public int getNumberOfMessages () Return the number of messsages in mailbox • public void removeMessage (int i) Remove the ith 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. 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_Orlowski 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 print AllMessages () method. Your output should look like Figure 3. 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).
Expert Answer:
Answer rating: 100% (QA)
ANSWER Mailboxjava package mailbox class Message variables String sender String recipient String messagetext default constructor Message thissender th... View the full answer
Related Book For
Fundamental Managerial Accounting Concepts
ISBN: 978-1259569197
8th edition
Authors: Thomas Edmonds, Christopher Edmonds, Bor Yi Tsay, Philip Olds
Posted Date:
Students also viewed these programming questions
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Demand function for a firm is given as P-100e, if the firm's average cost (AC) is AC 5+50, determine the firm's maximum profit. (5marks).
-
Identify the five number summary for the following data set: 35 24 54 2 36 23 16 43 59 55 28 81
-
A car traveling 75km / h slows down at a constant 0.50 m / s2 just by "letting up on the gas." Calculate (a) The distance the car coasts before it stops, (b) The time it takes to stop, and (c) The...
-
Why does increasing the time for a heat treatment mean recrystallization will occur at a lower temperature?
-
Two residents of California filed a lawsuit against Hertz Corporation on behalf of a group of people arguing that the companys labor practices were illegal. The corporation was labeling workers as...
-
The Raab Company is expanding its production facilities to include a new product line, a sporty automotive tire rim. Tire rims can now be produced with little labor cost using new computerized...
-
Define what is meant by an asset and a liability. Give an example of each.
-
Brian and Corrine Lee are married taxpayers filing jointly. They live in the home they own, located at 3301 Pacific Coast Hwy., Laguna Beach, CA 92651. Brian is an optometrist who owns his business;...
-
WAR (We Are Rich) has been in business since 1988. WAR is an accrual-method sole proprietorship that deals in the manufacturing and wholesaling of various types of golf equipment. Hack & Hack CPAS...
-
Discuss the long-term effects of organizational restructuring on employee well-being and the overall organizational climate?
-
As machines take on more jobs, many find themselves out of work or with raises indefinitely postponed. Is this the end of growth? No, says Erik Brynjolfsson -- it's simply the growing pains of a...
-
How do advancements in genomic sequencing technologies contribute to the identification of target genes for therapeutic intervention, and how does this inform the development of personalized gene...
-
The XYZ Corporation, a manufacturing company, uses accelerated depreciation for tax purposes but straight-line depreciation for financial reporting. As a result, the company's income tax expense...
-
How do advancements in synthetic biology and genome editing technologies, such as CRISPR-Cas systems and base editing tools, expand the capabilities of recombinant DNA technology to engineer complex...
-
A local manufacturing company produces heating and colling appliances for home and industrial applications. These include refrigerators, water coolers, water heaters, air conditioners, sandwich...
-
What is the order p of a B + -tree? Describe the structure of both internal and leaf nodes of a B + -tree.
-
Hebron Manufacturing Company started operations on January 1, 2019. During 2019, the company engaged in the following transactions: 1. Issued common stock for $100,000. 2. Paid $39,600 cash to...
-
Lumberton Home Maintenance Company (LHMC) earned operating income of $6,000,000 on operating assets of $62,500,000 during 2018. The Tree Cutting Division earned $1,000,000 on operating assets of...
-
Dalton Quilting Company makes blankets that it markets through a variety of department stores. It makes the blankets in batches of 1,000 units. Dalton made 20,000 blankets during the prior accounting...
-
Let \(\left\{\mathbf{X}_{n}ight\}_{n=1}^{\infty}\) be a sequence of \(d\)-dimensional random vectors where \(\mathbf{X}_{n}\) has distribution function \(F_{n}\) for all \(n \in \mathbb{N}\) and let...
-
Prove the converse part of the proof of Theorem 4.17. That is, let \(\left\{\mathbf{X}_{n}ight\}_{n=1}^{\infty}\) be a sequence of \(d\)-dimensional random vectors and let \(\mathbf{X}\) be a...
-
Let \(\left\{X_{n}ight\}_{n=1}^{\infty}\) and \(\left\{Y_{n}ight\}_{n=1}^{\infty}\) be sequences of random variables where \(X_{n}\) has a \(\mathrm{N}\left(\mu_{n}, \sigma_{n}^{2}ight)\)...
Study smarter with the SolutionInn App