I have this assignment to do. Its been about a year since I messed with c++ and I've been refreshing my brain on the subject. The assignment is this :

Your assignment is to write a program for a computer dating service. Each client gives you his or her name, phone number, and a list of interests. It is your job to maintain lists of men and women using the service and to match up the compatible couples. You will find more details about the assignment, including the inputs, outputs, and deliverables in the course environment.
Input
Data about current clients should be on file "Clients.mf". For each current client, the file contains the following information:

Sex 1 character, 'M' or 'F'
Name up to 20 characters, followed by comma
Phone Number 8 characters
Number of Interests an integer
List of Interests 10 characters each separated by commas with a period after the final interest.
Match up to 20 characters, followed by end-of-line.

From the keyboard: The user may enter on of the following commands.

Command Processing
NEWCLIENT <sex> <name> <number of interests> <interests> Add the client to the appropriate list by storing the appropriate information. Attempt to match this new client with a member of the opposite sex. A match occurs when the clients have three or more of the same interests. (You only have to find the first match for each new client.) Make sure you then designate both persons as matched, as described in the section on data structures above. Print the name of the new client, the name of his or her match, and both phone numbers. If no match is found, print an appropriate message.
UNMATCH <name> Unmatch this name with his or her current match by removing <name> from the matched person.
PRINTMATCH Print a list of all matched pairs.
PRINTFREE Print the names and phone numbers of clients who are not currently matched.
QUIT Stop processing


Output
Echo print all screen input and output on file "Dates.out."

Data Structures
The problem requires you to maintain two lists of clients, one for men and one for women. When a new client is added to the list, he or she is added to the end of the appropriate list.

Each list element must include all the information for one client: name, phone number, number of interests (maximum number is 10), interests, and the name of this client's current match (empty string if not matched). You must use one of the list classes developed in Chapter 3.

Deliverables
• Your design.
• A listing of your program
• A listing of your test plan as input to the program
• A listing of the output file

We can use either a linked list or array-based list. I'm having the hardest time just starting the thing. If anyone has the slightest clue on where to begin I would be forever grateful.

Start by creating a menu and inputting some data.

Next, add writing the data file.

Then read the data file and input more data.

Sit at your desk and continue designing the program piece by piece. When done with each piece, add it to the program.

Thanks for the tip, I'm going to give it a shot.

Okay...so I have my list coming together as I type this. It looks something like this.

class mList
{
private: 
	struct ListNode
	{
		
		char sex;
		char name[20];
		char phone[8];
		int numInterests;
		char interests[10][10];
		char match [20];


		struct ListNode *next;
	};

	ListNode *head;

public:
	mList()  //constructor
	{head = NULL;}
	~mList();  //destuctor

	
};

I think my main problem now is writing the functions that correspond to each command such as NEWCLIENT this process consist of : Add the client to the appropriate list by storing the appropriate information. Attempt to match this new client with a member of the opposite sex. A match occurs when the clients have three or more of the same interests. (You only have to find the first match for each new client.) Make sure you then designate both persons as matched, as described in the section on data structures above. Print the name of the new client, the name of his or her match, and both phone numbers. If no match is found, print an appropriate message.

How should I go about creating this process, will it be made up of a lot of comparing of data for each node?

Reread my previous post. You just mentioned like 4 different tasks. None of them are the basic tasks I mentioned. Have you finished those already?

And how long were you at your desk designing?

12+ hrs now, on and off. I used older code to construct my list. So you were saying, take the program one piece at a time? Then put them together? Its just, I couldn't figure out how to manipulate the data within the node and how to traverse the list itself; but I got that in pseudocode and I'm going to write it now.

Member Avatar for jmichae3

since you probably want persistence, I would go straight for an embedded postgresql database, or use the embedded database sqlite3. but only if you have time to do a bang-up job.
the language autoit(autoit3) at autoitscript.com has sqlite3 and it's a form of basic and it's easy to write a GUI.

I would just make a class for Person and a class for Match (make sure it has a constructor and destructor) and use the STL <list>.

#include <list>
#include <iterator>
#include <string>
using namespace std;
list<class Person> lpMen,lpWomen;
list<class Match> lmMatches;
list<class Person>::iterator lpiW, lpiM;
list<class Match>::iterator lmi;
int main(void) {
for (lpiM = lpMen.begin(); lpiM != lpMen.end(); lpiM++) {
    for (lpiW = lpWomen.begin(); lpiW != lpWomen.end(); lpiW++) {
        //handle criteria for a match
        if (lpiM->whatever() == lpiW->whatever()) {
            Match m;
            m.setman(*lpiM);
            m.setwoman(*lpiW);
            lmMatches.push_back(m); //add a new match to the list of matches
        }
    }
}

for (lmi = lmMatches.begin(); lmi != lmMatches.end(); lmi++) {
    //display man at lmi->getman() and woman at lmi at lmi->getwoman()
}

I would love to use something like that, it seems easier; but instructions were to use A class linked list. I have a piece of code that I think will traverse thru my list, does it seem right?

listNode *current;   //pointer to point at each node

current = head; //points to beginning of list

while(current != NULL)  //loop to go thru

{

     current = current->next;

}

since you probably want persistence, I would go straight for an embedded postgresql database, or use the embedded database sqlite3. but only if you have time to do a bang-up job.
the language autoit(autoit3) at autoitscript.com has sqlite3 and it's a form of basic and it's easy to write a GUI.

I'm sure the instructor is looking for exactly this level of programming. He's probably going to teach Oracle and AI next week. :icon_rolleyes:

I would love to use something like that, it seems easier; but instructions were to use A class linked list. I have a piece of code that I think will traverse thru my list, does it seem right?

listNode *current;   //pointer to point at each node

current = head; //points to beginning of list

while(current != NULL)  //loop to go thru

{

     current = current->next;

}

Yes.

Member Avatar for jmichae3

I would love to use something like that, it seems easier; but instructions were to use A class linked list. I have a piece of code that I think will traverse thru my list, does it seem right?

listNode *current;   //pointer to point at each node

current = head; //points to beginning of list

while(current != NULL)  //loop to go thru

{

     current = current->next;

}

you could even implement a
Node* Node::next() {
}
method which returns the next pointer as part of your Node interface.

the while loop should be outside the Node class of course, possibly part of the list class. you get the idea for the masic design. the Match class should have a Woman Node and a Man Node inside as members, and you should provide access methods to them like
void setman(class Node& n)
void setwoman(class Node& n)
void getman(class Node& n)
void getwoman(class Node& n)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.