C++ project HELP

April 15, 2009 at 15:46:05
Specs: Windows 7
I'm new to C++ and i have a project to complete. But i can't seem to come up with the code. I already wrote the code for the cards but i can't come up with the code for the information manager. Can somebody help me?
This goal of this project is to build an information manager similar to a rolodex (see http://en.wikipedia.org/wiki/Rolodex). A physical rolodex is made up of cards arranged in alphabetical order by [Last Name, First Name]. Each card contains some information, usually name, address, phone number and type of business (why the person is in the rolodex). The physical mechanism of using a rolodex is turning the group of cards and flipping through them. When the last card is read, the rolodex is then at the start of the list since a rolodex is built on a circular track.

Provide the following interactive commands in main() to work with your rolodex:

* list - displays all the cards in the rolodex, in alphabetical order from beginning to end.
* view - displays the card at the current position.
* flip - updates the current position to the next card, and displays it. Flipping past the last card wraps around to the first card.
* search - finds and displays a card, and makes it the current position in the rolodex. This command prompts for the last name for searching. If a matching card is found, it is displayed and is set as the current position. If no matching card is found, the card that immediately follows the lookup name is displayed and set as the current position (e.g. if "H" is entered as the last name, the first card with a last name following "H" in alphabetical order is displayed). If there is no following card, displays "Couldn't find: name"
* add - adds a new card to the rolodex. Prompts for each field value, reads it, and enters the new card in the correct position in the rolodex (based on alphabetical order). The new card is set as the current position.
* remove - removes the card at the current position. It displays the card and prompts for a confirmation for removal. The following card is set as the current position.
* modify - updates the card at the current position. Enters a mode that requests the field to be updated (e.g. phone #), displays the existing value and prompts for the new value, reads it, and updates the card. Continues prompting for additional changes until all changes are done (e.g. a 0 is entered for the field # to change). If the last name is changed, the card must be moved to the correct position in the rolodex (and is set as the current position).
* quit - exits the program.

Use the following information to provide the initial information to demonstrate the functionality of your rolodex program. You can hardcode these entries into your rolodex initialization in main() to simulate reading the information from a file..

The Standard Library std::string class should be used for the character information (no char* or char arrays).

Individual cards should be represented by objects of a user defined class (e.g. Card or RoloCard). Member functions of this class should allow getting and setting of data values (e.g. first name), and possibly a display function that knows how to display the card on the supplied ostream parameter. This class does not know about Rolodex functionality, it just encapsulates a single card's information.

A Rolodex class should use an STL container class as a data member to hold the set of rolodex cards, and associated iterator to reference the current card. The container used must be able to handle the case of duplicate names (e.g. two of Jim Smith, etc). The member functions of this class manage the collection of cards, and may have parameters or return values that are a Card object. For example:

* The add() member function should have a Card parameter, so that the main() code adding a card first does the interaction with the user to get the info for the new card, constructs the Card object, and then finally calls the Rolodex.add() method, passing the Card object to be added to the rolodex. The Rolodex.add() method shouldn't do all the interaction with the user or create the Card (that's done by the caller). It just adds its parameter Card object to the Rolodex collection of cards (in the correct position), and updates its iterator to refer to the new card as the current position.
* The list() member function should use a local iterator to iterate through the collection of cards and display them. It can have an ostream parameter that the output should be displayed to, and can call each card's display member function for the output. It doesn't know how to display the card's data, rather, it requests each card to display its data on the provided ostream parameter.
* A modify can be done by the code in main() getting the current card, performing the interactions to modify its value(s), and then if the modify is approved by the user, call the Rolodex.remove() function to remove the (old) card from the collection, and then Rolodex.add() to add the modified card to the collection. Here again, the Rolodex class knows nothing about how to modify the contents of a card. Most of the work is done in the main() function that interacts with the user, and then the Rolodex functions are used to simply remove the old card and add back the modified card (which may have a changed last name, so it would be added back at a different position in the collection).

See More: C++ project HELP

Report •

April 15, 2009 at 20:16:01
You mention an information manager and cards.

From the requirements there is at least one, and probably several other object types involved.

Are those types also a part of your design and attempted implementation? If so, describe. If not, why not?


Report •

April 15, 2009 at 22:00:54
There's only one type of object involved(Card). They contain information such as name, address, phone number...etc. I already defined a class named card which contains this information.

My problem is with the Rolodex class which manipulates this data.


Report •

April 16, 2009 at 17:22:55
Jack - From your description, you already have at least two types in your attempted implementation:

1) Card
2) Rolodex

A type will manifest itself in a formal class definition and an implementation.

There are many other possible types implied in the requirements: Person, Name, Address, ....yada, yada .... and even perhaps a RolodexManipulator. But maybe a Rolodex should know how to manipulate itself. A design decision.

Describe your design.

Describe your attempted implementation.

Describe more specifically what your current problem is.


Report •

Related Solutions

April 16, 2009 at 18:00:15
Suggestion - put your code in to a modern source control system.

Any of git, hg, or bzr will do, at least for me.

Publish the project to a place where others can obtain the code: github, unfuddle, ......

You might obtain more help if others can actually see what you are attempting to do.

Has your prof mentioned 'source control'?


Report •

April 18, 2009 at 09:04:08

class Card

Card( string first, string last, string address, string occupation, string phone);
string getfirst();
string getlast();
string getaddress();
string getoccupation();
string getphone();
string cardinfo(); //prints card information, i used ostringstream to print info.

string first, last, address, occupation, phonenumber;

class Rolodex
void list();
void search();
void remove();
void modify();
void add();
void flip();
void view();
void quit();

list <Rolodex> nCard;

My problem is i'm having problem implementing rolodex

Report •

April 18, 2009 at 14:30:58
1) The Card specification needs setters. The requirements specifically call for that.

2) The cardinfo member of Card needs to take an ostream as a parameter. The requirements specifically call for that.

3) The Rolodex specification needs an iterator for the collection of Cards. The requirements specifically call for that.

4) The Rolodex class needs to contain a collection of Cards, not a collection of Rolodexes as you have shown.

5) The requirements seem to imply that the collection of Cards should be a set, not a list, but that is not totally clear.

6) The add member function of Rolodex needs to take a Card as a parameter. Again specified in the requirements. The remove member function probably does as well.

I suggest you carefully reread the requirements, rework the interface definitions, and then take another run at implementation.


After thinking about my comment 5) above for a couple of days, I believe it is incorrect. This problem seems to beg for a multimap collection as a solution.


Report •

April 24, 2009 at 03:44:27
i probably will fail cause I wont have time to complete it
I thought of multimap but then again you need a set of keys for Multimap.

Report •

April 25, 2009 at 14:07:46
Yes, I am sure students do not have time. Ya'll are certainly working 60+ hrs / week normally like most of us.

You do not need a formal 'set' of keys to use a multimap.

You can compose a key, e.g. in pseudo code:

string key = lastName + ", " + firstName;

? Can you answer my question about source control systems? Do you know what those are? And do you have a client installed?

Report •

Ask Question