Question

Implement the Message class using a header and implementation file named Message.h and Message.cpp respectively. In...


Implement the Message class using a header and implementation file named Message.h and
Message.cpp respectively. In addition to the two Message class files, you must write a driver. The driver
must create a Message array that is capable of holding 100 messages (make sure that you don’t exceed
the maximum number of Messages). It then must read all Messages from a file named messages.txt
(ordered date\n sender\n recipient\n body\n), sort the Messages based on date, find a Message based on
messageID (value will be given by keyboard input), and print the first five Messages and the Message
resulting from the search. (I suggest that you use one of the sort and one of the search algorithms).

Attributes
string sender – string containing the e-mail address of the sender (e.g. [email protected]).

string recipient – string containing the e-mail address of the recipient(e.g. [email protected]).

string body – string containing the message or body of the e-mail.

string date – string containing the date (timestamp) for the message in the form yyyy/mm/dd.

int messageID – integer that stores a unique identifier for each message.

static int messageIDGen – integer used to provide a unique identifier for messageID.

messageIDGen must be initialized outside of the class definition (e.g. Place the

initialization in the implementation file) (HINT:. int Message::messageIDGen = 0).

Member Functions:
Message( )
   Default Constructor that increments the messageIDGen and assigns it’s value to messageID.
Message(string, string, string, string)
  
Constructor with initialization stings for sender, recipient, body, and date. It will also increments
   messageIDGen and assigns it’s value to messageID.
~Message( )
   Destructor
void setSender(string)
   Modifier that allows the user to set the sender string
void setRecipient(string)
   Modifier that allows the user to set the recipient string
void setBody(string)
   Modifier that allows the user to set the body of the message
void setDate(string)
   Modifier that allows the user to set the timestamp of the message
string getSender( )
   Accessor that allows the user to get the sender string
string getRecipient( )
   Accessor that allows the user to get the recipient string
string getBody( )
   Accessor that allows the user to get the body of the message
string getDate( )
   Accessor that allows the user to get the timestamp of the message
int getMessageID( )
   Accessor that allows the user to get the value of messageID
string toString( )
   Function that returns a string representation of a Message object. (You may need to alter the
   code below to match output)

messageID: 12
date: 2006/11/20
sender: [email protected]
recipient: [email protected]
body: Hope your semester is going well!
#include
string toString()
{
ostringstream result;
result << “messageID: “ << messageID << endl;
result << “date: “ << date << endl;
result << “sender: “ << sender << endl;
result << “recipient: “ << recipient << endl;
result << “body: “ << body << endl;
return result.str();
}

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Implement the Message class using a header and implementation file named Message.h and Message.cpp respectively. In...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • In Problem Set 7 you designed and implemented a Message class. This time, let's design and...

    In Problem Set 7 you designed and implemented a Message class. This time, let's design and implement a Mailbox class in a file named Mailbox java. Do the following with this class • You may use the Message class from PS 7. You will have to add new features to the Message class from PS 7 as you work through this problem. You are welcome to start with my sample solution if you wish • Suppose there are multiple mail...

  • Write a C++ Program. You have a following class as a header file (dayType.h) and main()....

    Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public:     static string weekDays[7];     void print() const;     string nextDay() const;     string prevDay() const;     void addDay(int nDays);     void setDay(string d);     string getDay() const;     dayType();     dayType(string d); private:     string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...

  • Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter...

    Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter and CertifiedLetter and that demonstrates all their methods. The classes are used by a company to keep track of letters they mail to clients. The Letter class includes auto-implemented properties for the Name of the recipient and the Date mailed (stored as strings). Next, include a ToString() method that overrides the Object class’s ToString() method and returns a string that contains the name of...

  • Write a C++ program that includes the following: Define the class Student in the header file Stu...

    Write a C++ program that includes the following: Define the class Student in the header file Student.h. #ifndef STUDENT_H #define STUDENT_H #include <string> #include <iostream> using namespace std; class Student { public: // Default constructor Student() { } // Creates a student with the specified id and name. Student(int id, const string& name) { } // Returns the student name. string get_name() const { } // Returns the student id. int get_id () const { } // Sets the student...

  • Using the Die class defined in this chapter, design and implement a class called PairOfDice, composed...

    Using the Die class defined in this chapter, design and implement a class called PairOfDice, composed of two Die objects. Include methods to set and get the individual die values, a method to roll the dice, and a method that returns the current sum of the two die values. Create a driver class called RollingDice2 to instantiate and use a PairOfDice object. I need the main method or test class public class Die { private final int MAX = 6;...

  • I only need the "functions" NOT the header file nor the main implementation file JUST the impleme...

    I only need the "functions" NOT the header file nor the main implementation file JUST the implementations for the functions Please help, if its difficult to do the complete program I would appreciate if you could do as much functions as you can especially for the derived class. I am a beginer so I am only using classes and pointers while implementing everything using simple c++ commands thank you in advanced Design and implement two C++ classes to provide matrix...

  • given the following two classes Within a file named Rational.java, define a public class named Rational...

    given the following two classes Within a file named Rational.java, define a public class named Rational such that … the Rational class has two private instance variables, numerator and denominator, both of type int the Rational class defines two public accessor methods, numerator() and denominator() the Rational class defines a constructor that has one String parameter a throws clause indicates that this constructor could potentially throw a MalformedRationalException this constructor throws a MalformedRationalException in the following circumstances … When the...

  • C++ (Using Binary Search Trees) other methods will result in downvote Implement the binary search tree...

    C++ (Using Binary Search Trees) other methods will result in downvote Implement the binary search tree methods (bst.cpp) for the binary search tree provided in the header file. Test your implementation with the included test. bst.h bst_test.cpp Note: Your implementation must correspond to declarations in the header file, and pass the test. Do not modify these two. I will compile your code against these. If the compilation fails, you will get down vote. bst.h #ifndef BINARY_SEARCH_TREE_H #define BINARY_SEARCH_TREE_H #include <string>...

  • This is my assignment prompt This is an example of the input and output This is...

    This is my assignment prompt This is an example of the input and output This is what I have so far What is the 3rd ToDo in the main.cpp for open the files and read the encrypted message? Does the rest of the code look accurate? Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to a...

  • Need this in C++ Goals: Your task is to implement a binary search tree of linked...

    Need this in C++ Goals: Your task is to implement a binary search tree of linked lists of movies. Tree nodes will contain a letter of the alphabet and a linked list. The linked list will be an alphabetically sorted list of movies which start with that letter. MovieTree() ➔ Constructor: Initialize any member variables of the class to default ~MovieTree() ➔ Destructor: Free all memory that was allocated void printMovieInventory() ➔ Print every movie in the data structure in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT