
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
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., 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: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

arrow_forward
Step 1
The answer is given below:-
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 3 images

Knowledge Booster
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
- class implementation file -- Rectangle.cpp class Rectangle { #include #include "Rectangle.h" using namespace std; private: double width; double length; public: void setWidth (double); void setLength (double) ; double getWidth() const; double getLength() const; double getArea () const; } ; // set the width of the rectangle void Rectangle::setWidth (double w) { width = w; } // set the length of the rectangle void Rectangle::setLength (double l) { length l; //get the width of the rectangle double Rectangle::getWidth() const { return width; // more member functions herearrow_forwardclass IndexItem { public: virtual int count() = 0; virtual void display()= 0; };class Book : public IndexItem { private: string title; string author; public: Book(string title, string author): title(title), author(author){} virtual int count(){ return 1; } virtual void display(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };class Category: public IndexItem { private: /* fill in the private member variables for the Category class below */ ? int count; public: Category(string name, string code): name(name), code(code){} /* Implement the count function below. Consider the use of the function as depicted in main() */ ? /* Implement the add function which fills the category with contents below. Consider the use of the function as depicted in main() */ ? virtualvoiddisplay(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };arrow_forward#Python IDLE: #Below is my Pizza class ,how would I write the function described in the attached image,based on this class? # The Pizza class should have two attributes(data items): class Pizza: # The Pizza class should have the following methods/operators): # __init__ - # constructs a Pizza of a given size (defaults to ‘M’) # and with a given set of toppings (defaults to empty set). def __init__(self, size='M', toppings=set()): self.size = size self.toppings = toppings # setSize – set pizza size to one of ‘S’,’M’or ‘L’ def setSize(self, size): self.size = size # getSize – returns size def getSize(self): return self.size # addTopping – adds a topping to the pizza, no duplicates, i.e., adding ‘pepperoni’ twice only adds it once def addTopping(self, topping): self.toppings.add(topping) # removeTopping – removes a topping from the pizza def removeTopping(self, topping):…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education