Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-07-2008, 12:21 PM
uoitcheater uoitcheater is offline
Newbie
 
Join Date: Mar 2008
Posts: 1
Rep Power: 0
uoitcheater is on a distinguished road
Post C++ Email Structure Program

I'm posting this to anyone who can do it, I'm not really having any problems with it... I just can 't even begin to get what I need to do in the question... If you can't do it or think I'm just lazy, please don't leave your angry comments, I'm just looking for an answer to this very difficult question. I've been tring for the past week nad have gotten no where.

Design a class Mailbox that stores mail messages, using the Message class “Message.h” and “Message.cpp” included as part of the assignment. You don't yet know how to store a collection of message objects. Instead, use the following brute force approach: The mailbox contains one very long string, which is the concatenation of all messages. You can tell where a new message starts by searching for a From: at the beginning of a line. This may sound like a dumb strategy, but surprisingly, many e-mail systems do just that. Implement the following member functions:

void Mailbox::add_message(Message m);
Message Mailbox::get_message(int i) const;
void remove_message(int i) const;

What do you do if the message body happens to have a line starting with "From:"? Then the to_string function of the Message class should really insert a > in front of the From: so that it reads >From:. Again, this sounds dumb, but it is a strategy used by real e-mail systems.

the two codes that are given are:
[code]
Message.cpp



Code:
Code:
#include <iostream>
#include <string>
#include "Message.h"

using namespace std;


Message::Message()
{
}

Message::Message(string r, string s)
{
   recipient = r;
   sender = s;
}

void Message::append(string t)
{
   string from = "From: ";
   if (t.substr(0, from.length()) == from)
      text = text + ">" + t + "\n";
   else
      text = text + t + "\n";
}

string Message::to_string() const
{
   return "From: " + sender + "\n" +
      "To: " + recipient + "\n" + text;
}

void Message::print() const
{
   cout << to_string();
}and the header Message.h
Code:
Code:
#ifndef MESSAGE_H
#define MESSAGE_H

#include <iostream>
#include <string>

using namespace std;

class Message
{
public:
   Message();
   Message(string r, string s);
   void append(string t);
   string to_string() const;
   void print() const;

private:
   string recipient;
   string sender;
   string text;
};

#endif
Thankyou for taking the time to read my question.

Last edited by WingedPanther; 03-08-2008 at 11:12 AM. Reason: add code blocks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 03-08-2008, 11:14 AM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,421
Last Blog:
wxWidgets is NOT code ...
Rep Power: 37
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default Re: C++ Email Structure Program

I guess my real question is: where are you having difficulty. Are you not sure what your strategy should be, or having issues with the code?

Also, please use code blocks with your code.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Programming is a branch of mathematics.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-13-2008, 12:24 AM
lol_its_u lol_its_u is offline
Newbie
 
Join Date: Apr 2008
Posts: 1
Rep Power: 0
lol_its_u is on a distinguished road
Default lol

............... tfss
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unique & Complex Sorting Program ryan.devani C and C++ 3 01-17-2008 01:28 PM
Help with Square root and calculator program!!! 123456789asdf C and C++ 10 12-02-2007 05:35 PM
PHP:Tutorial - Email Verification John PHP Tutorials 3 09-19-2007 01:19 PM


All times are GMT -5. The time now is 11:31 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 101%


Complete - Celebrate!

Ads