Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,569 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,917 people online right now. Registration is fast and FREE... Join Now!




Final Program -EmailList

 
Reply to this topicStart new topic

Final Program -EmailList, C++ program

kaantexas
5 May, 2008 - 02:34 PM
Post #1

New D.I.C Head
*

Joined: 12 Jan, 2008
Posts: 14

I need to write a program that provides for the storage and retrieval of a set of objects (records) for email addresses and websites. Each object must have a data element for: the name of the person (or company), the email address, and the website. The program must have a user interface that allows the following operations:

1. Add: Adds a new object for a person's or a company's data
2. Delete: Delete a given person's object
3. Change: Allows the editing of the information in an object
4. Find: Search for a specific object in the list of objects.
5. Quit: Exit from the application.

Design and implement a class to store data about each entry. Name this class EMailObjs. This class should have appropriate data elements for storing a name, email address, and website URL. Provide for access methods for setting and retrieving data.

Design and implement a class to store a collection of email elements (EMailObjs). Name this class EMailList. An element of this object will be a collection of EMailObjs implemented through the use of one of the data structures in the STL. Provide appropriate member functions to manage
this collection of data.

The EMailList should have member functions to save and restore data to a text file. Data should be read from a file when the program starts and save data to a file when it terminates.

The user interface should also be implemented as a class with appropriate member functions for each of the required operations. Name this class UserInterface.

This program must use: file streams, exception handling, object oriented technology, class templates and the STL. It should also use, where appropriate, operator overloading and friend functions.

I already started one of the functions. Still working functions add, find, change and quit.

and also I use char instead of string. is that acceptable?

..........
using namespace std;
struct EmailObjs
{
char name;
char email;
char website;
};


list <EmailObjs> EmailList;

void deleteObject();
void add();
void find();

void change();
void quit();
void search (string, bool, list<EmailObjs>::iterator &);

........................

User is offlineProfile CardPM
+Quote Post

kaantexas
RE: Final Program -EmailList
5 May, 2008 - 04:05 PM
Post #2

New D.I.C Head
*

Joined: 12 Jan, 2008
Posts: 14

QUOTE(kaantexas @ 5 May, 2008 - 03:34 PM) *

I need to write a program that provides for the storage and retrieval of a set of objects (records) for email addresses and websites. Each object must have a data element for: the name of the person (or company), the email address, and the website. The program must have a user interface that allows the following operations:

1. Add: Adds a new object for a person's or a company's data
2. Delete: Delete a given person's object
3. Change: Allows the editing of the information in an object
4. Find: Search for a specific object in the list of objects.
5. Quit: Exit from the application.

Design and implement a class to store data about each entry. Name this class EMailObjs. This class should have appropriate data elements for storing a name, email address, and website URL. Provide for access methods for setting and retrieving data.

Design and implement a class to store a collection of email elements (EMailObjs). Name this class EMailList. An element of this object will be a collection of EMailObjs implemented through the use of one of the data structures in the STL. Provide appropriate member functions to manage
this collection of data.

The EMailList should have member functions to save and restore data to a text file. Data should be read from a file when the program starts and save data to a file when it terminates.

The user interface should also be implemented as a class with appropriate member functions for each of the required operations. Name this class UserInterface.

This program must use: file streams, exception handling, object oriented technology, class templates and the STL. It should also use, where appropriate, operator overloading and friend functions.

I already started one of the functions. Still working functions add, find, change and quit.

and also I use char instead of string. is that acceptable?

..........
using namespace std;
struct EmailObjs
{
char name;
char email;
char website;
};


list <EmailObjs> EmailList;

void deleteObject();
void add();
void find();

void change();
void quit();
void search (string, bool, list<EmailObjs>::iterator &);

........................


And also I am not sure how can I use all this criteria together: file streams, exception handling, object oriented technology, class templates and the STL. It should also use, where appropriate, operator overloading and friend functions.

User is offlineProfile CardPM
+Quote Post

realNoName
RE: Final Program -EmailList
5 May, 2008 - 05:40 PM
Post #3

D.I.C Regular
***

Joined: 4 Dec, 2006
Posts: 299



Thanked: 5 times
My Contributions
QUOTE(kaantexas @ 5 May, 2008 - 03:34 PM) *

and also I use char instead of string. is that acceptable?

..........
using namespace std;
struct EmailObjs
{
char name;
char email;
char website;
};


yes and no... yes you can use char's but your going to make it alot more work and you will have to use char arrays ( char name[SIZE] ) as of right now you can only hold 1 character


QUOTE(kaantexas @ 5 May, 2008 - 05:05 PM) *

And also I am not sure how can I use all this criteria together: file streams, exception handling, object oriented technology, class templates and the STL. It should also use, where appropriate, operator overloading and friend functions.

file streams -> store all the data in them
exception handling -> the main thing i would use this for is error handling with opening / read / write to the file
oop -> make an object something like mailingList and have name,email,website as the data
stl -> your data in the mailingList object (name,email,website) could be vectors (a.k.a kick ass array class)
overloading -> overload the ostream operator to make it easy to print / save the data, this could also be your friend function


if you need help with string / stl this is a great site

this is a start of the class i was talking about... this is just how i would do it i know there are other ways but this should help you get a better idea
CODE
#ifndef MAILING_LIST
#define MAILING_LIST
class mailingList
{
    public:
        mailingList();
        friend ostream & <<operator(ostream & out, mailingList & obj);

    private:
        vector<string> name;
        vector<string> email;
        vector<string> website;
    
};
#endif


if there is something you need help with we need you to get some code going and we can help you more

User is offlineProfile CardPM
+Quote Post

kaantexas
RE: Final Program -EmailList
6 May, 2008 - 07:35 AM
Post #4

New D.I.C Head
*

Joined: 12 Jan, 2008
Posts: 14

I think you are right. vector is better...

QUOTE(realNoName @ 5 May, 2008 - 06:40 PM) *

QUOTE(kaantexas @ 5 May, 2008 - 03:34 PM) *

and also I use char instead of string. is that acceptable?

..........
using namespace std;
struct EmailObjs
{
char name;
char email;
char website;
};


yes and no... yes you can use char's but your going to make it alot more work and you will have to use char arrays ( char name[SIZE] ) as of right now you can only hold 1 character


QUOTE(kaantexas @ 5 May, 2008 - 05:05 PM) *

And also I am not sure how can I use all this criteria together: file streams, exception handling, object oriented technology, class templates and the STL. It should also use, where appropriate, operator overloading and friend functions.

file streams -> store all the data in them
exception handling -> the main thing i would use this for is error handling with opening / read / write to the file
oop -> make an object something like mailingList and have name,email,website as the data
stl -> your data in the mailingList object (name,email,website) could be vectors (a.k.a kick ass array class)
overloading -> overload the ostream operator to make it easy to print / save the data, this could also be your friend function


if you need help with string / stl this is a great site

this is a start of the class i was talking about... this is just how i would do it i know there are other ways but this should help you get a better idea
CODE
#ifndef MAILING_LIST
#define MAILING_LIST
class mailingList
{
    public:
        mailingList();
        friend ostream & <<operator(ostream & out, mailingList & obj);

    private:
        vector<string> name;
        vector<string> email;
        vector<string> website;
    
};
#endif


if there is something you need help with we need you to get some code going and we can help you more


User is offlineProfile CardPM
+Quote Post

kaantexas
RE: Final Program -EmailList
6 May, 2008 - 07:53 AM
Post #5

New D.I.C Head
*

Joined: 12 Jan, 2008
Posts: 14

I created .h file with friend function and vector function. Do you think I should get another .h file or keep everything in .cpp file?
And also this is the .cpp file and I am not sure how I can use "vector" and "friend function" in here...

#include "EmailObjs.h"
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cstring>
#include <ctype.h>
#include <conio.h>

//add STL list class, iterators, and algorithms
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;

// add an STL vector
vector<DataType> List;

int main()
{
void add();
void dodelete();
void change();
void find();
void quit();

int pos = 0;
char choice,ch;
// remove List.Initialize();
// add
List.clear();
do {
menu(choice);
switch(toupper(choice))
{
case 'A' : addt();
break;
case 'D' : dodelete();
break;
case 'F' : change();
break;
case 'F' : find();
break;
case 'Q' : break;
default : cout << "Error in choice: ";
cin.get(ch);
break;
}
}
while (toupper(choice) != 'Q');

// remove List.ClearList();
// add
List.clear();
}

void menu(char& choice)
{
char eoln;
cout << "\n\n\n\n\n";
cout << " List Manager Menu \n";
cout << " =========================== \n";
cout << " Add....................A \n";
cout << " Delete....................D \n";
cout << " Change......................C \n";
cout << " Find..................F \n";
cout << " Quit......................Q \n";
cout << " =========================== \n";
cout << " -----------> ";
cin >> choice;
cin.get(eoln);
}


Thanks


QUOTE(kaantexas @ 6 May, 2008 - 08:35 AM) *

I think you are right. vector is better...

QUOTE(realNoName @ 5 May, 2008 - 06:40 PM) *

QUOTE(kaantexas @ 5 May, 2008 - 03:34 PM) *

and also I use char instead of string. is that acceptable?

..........
using namespace std;
struct EmailObjs
{
char name;
char email;
char website;
};


yes and no... yes you can use char's but your going to make it alot more work and you will have to use char arrays ( char name[SIZE] ) as of right now you can only hold 1 character


QUOTE(kaantexas @ 5 May, 2008 - 05:05 PM) *

And also I am not sure how can I use all this criteria together: file streams, exception handling, object oriented technology, class templates and the STL. It should also use, where appropriate, operator overloading and friend functions.

file streams -> store all the data in them
exception handling -> the main thing i would use this for is error handling with opening / read / write to the file
oop -> make an object something like mailingList and have name,email,website as the data
stl -> your data in the mailingList object (name,email,website) could be vectors (a.k.a kick ass array class)
overloading -> overload the ostream operator to make it easy to print / save the data, this could also be your friend function


if you need help with string / stl this is a great site

this is a start of the class i was talking about... this is just how i would do it i know there are other ways but this should help you get a better idea
CODE
#ifndef MAILING_LIST
#define MAILING_LIST
class mailingList
{
    public:
        mailingList();
        friend ostream & <<operator(ostream & out, mailingList & obj);

    private:
        vector<string> name;
        vector<string> email;
        vector<string> website;
    
};
#endif


if there is something you need help with we need you to get some code going and we can help you more



User is offlineProfile CardPM
+Quote Post

kaantexas
RE: Final Program -EmailList
6 May, 2008 - 07:01 PM
Post #6

New D.I.C Head
*

Joined: 12 Jan, 2008
Posts: 14

I did without using object oriented technology, class templates and the STL. I should also use, where appropriate, operator overloading and friend functions.

And also Delete and Find function dont work.


#include <fstream>
#include <iostream>
using namespace std;

/* globals */
const int FIRST_NAME = 15;
const int LAST_NAME = 15;
const int E_MAIL = 30;
const int WEBSITE = 20;

struct EmailList
{
char fname[FIRST_NAME];
char lname[LAST_NAME];
char email[E_MAIL ];
char link[WEBSITE];

};


void Add(fstream &datafile,int &num_names)
{
EmailList temp;
int i;

cin.get();

cout << "\nLast name? ";
cin.getline(temp.lname,FIRST_NAME);


cout<<"First name? ";
cin.getline(temp.fname, FIRST_NAME);


cout <<"Email address ";
cin.getline(temp.email, E_MAIL);


cout<<"Website ";
cin.getline(temp.link, WEBSITE);


num_names++;
datafile.seekp(0);
datafile.write((char *) & num_names,sizeof(num_names));


datafile.seekp(sizeof(num_names) + (num_names-1)*sizeof(EmailList));
datafile.write((char *) &temp, sizeof(EmailList));

for ( i= 0; i< num_names; i++)
{
}


cout << endl << temp.fname<<" "<<temp.lname <<" added as record "<<i;
}

/*
void Delete(fstream &datafile,char num_names)
........


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 11:55PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month