Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ Program that does the following. please only post if works. looking for comp

ID: 649117 • Letter: C

Question

c++ Program that does the following.
please only post if works.
looking for complete code nothing complicated,
also comments in code will be greatly appreciated. thank you!

Step 1: Design a class Message that models an e-mail message. A message has a recipient, a sender, and a message text. Support the following member functions: • A constructor that takes the sender and recipient • A member function that appends a line of text to the message body • A member function that makes the message into one long string like this: "From: John Adams To: Adam Jones ..." • Any other member functions that you need, e.g. the get and set functions.

Step 2: Design a class Mailbox that stores e-mail messages, using the Message class from step 1. Implement the following member functions: • A member function that adds messages • A member function that looks for the first message that matches the sender and recipient entered by user. • A member function that deletes the first message that matches the sender and recipient entered by user • Any other member functions that you need

Explanation / Answer

// Message.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include "string.h"

#include "iostream"

#include "vector"

using namespace std;

// class Message

class Message

{

       // private variables

       string messg,sender,recepient;

      

       // constructor

       Message(string sndr,string rcpnt)

       {

              sender=sndr;

              recepient=rcpnt;

              messg="";

       }

       // method add message

       void addMessage(string msg)

       {

              // add a line to the message

              messg = messg.append(" ");

              messg.append(msg);

       }

       // method getting the full message in one string

       void compMessage()

       {

              string fullmesg;

              // get the sender

              string msgfrom= "From : ";

              msgfrom.append(sender);

              // get the recipient

              string msgto = "To : ";

              msgto.append(recepient);

              // add them to the messages

           fullmesg = msgfrom;

              fullmesg.append(" ");

              fullmesg.append(msgto);

              fullmesg.append(" ");

              fullmesg.append(messg);

              messg=fullmesg;

       }

       // get and set methods for the sender and the recipients

       void Sender(string sndr)

       {

              sender=sndr;

       }

       string Sender()

       {

              return sender;

       }

       void Recipient(string rcpnt)

       {

              recepient=rcpnt;

       }

       string Recipient()

       {

              return recepient;

       }

};

class MailBox

{

       vector<Message> mail;

       // add messages to Mailbox

       void addMail(Message msg)

       {

              mail.push_back(msg);

       }

       // get the message whose sender and recipient matches

       Message findMail(string sender,string recipient)

       {

              for(Message msg : mail)

              {

                     if (msg.Sender == sender && msg.Recipient == recipient)

                     {

                           return msg;

                     }

              }

       }

       // delete the message whose sender and recipient matches

       void deleteMail(string sender,string recipient)

       {

              int cnt=0;

              for(Message msg : mail)

              {

                     cnt++;

                     if (msg.Sender == sender && msg.Recipient == recipient)

                     {

                           mail.erase(mail.begin + cnt);

                           break;

                     }

              }

       }

};

void main()

{

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote