M Dr.Gregory House,237-8732 7 Vicodin,Guitar,Piano,Motorcycles,Television,Food,W hiteboards.endl; (all on a single line).
First, is the sex (M or F), then the person's name, phone number, number of interests, then a list of their interests (with commas between each one, and a period at the end.) and then if they have a match you put their name there and put endl; after.
The main problem I'm having is setting up the link list, I have no idea how to get it to read those as variables in the text, I know you have to use delimiters, but I can't quite figure out how to use them. You also have to keep two lists, one for males, and one for females in the output file. How do I do this? Is that a double linked list?
Any help would really be appreciated. Thank you!
Here is the code so far (I know it isn't much..)
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <limits>
- #include <cstring>
- using namespace std;
- //Functions
- void echoPrint();
- void newClient();
- void unMatch();
- void printMatch();
- void printFree();
- void quitAsking();
- void processing();
- //Initialize Variables
- string command = ""; // User command answer
- std::string clientSex;
- std::string clientName;
- std::string clientPhone;
- std::string clientNumInt;
- std::string clientInterests;
- std::string match;
- ifstream inputfile;
- char Clients[] = "Clients.mf.txt"; // Input file
- ofstream outputfile;
- char Dates[] = "Dates.out.txt"; // Output file
- int main(){
- inputfile.open(Clients, ios::in);
- //If input file can't open, read out this
- if (!inputfile) {
- cerr << "Can't open input file " << Clients << endl;
- exit(1);
- }
- outputfile.open(Dates, ios::out);
- // If output file can't open, read out this
- if (!outputfile){
- cerr << "Can't open output file " << Dates << endl;
- exit(1);
- }
- //Questions & command list
- cout << "Hello, how may I help you today?" << endl;
- cout << endl;
- cout << "Here are a list of commands I can do:" << endl;
- cout << endl;
- cout << "NEWCLIENT- Add a new client to my database" << endl;
- cout << "UNMATCH- Remove client's current match" << endl;
- cout << "PRINTMATCH- Print a list of all matched clients" << endl;
- cout << "PRINTFREE- Prints the names and numbers of all clients without matches" << endl;
- cout << "QUIT- This will exit the program." << endl;
- cout << endl;
- cout << "Please choose a command from above." << endl;
- //Sends program to processing function
- processing();
- do{
- cout << "What would you like to do now? Please enter another command." << endl;
- // Sends program to processing function
- processing();
- }while(command == "QUIT" || command == "quit");
- }// Closes main
- void processing(){
- do{
- cin >> command;
- if (command == "NEWCLIENT" || command == "newclient"){
- newClient();
- }else if
- (command == "UNMATCH" || command == "unmatch"){
- unMatch();
- }else if
- (command == "PRINTMATCH" || command == "printmatch"){
- printMatch();
- }else if
- (command == "PRINTFREE" || command == "printfree"){
- printFree();
- }else if
- (command == "QUIT" || command == "quit"){
- quitAsking();
- }else
- {
- cout <<"****ERROR**** Please choose a command from above." << endl;
- // Only allows error message to print once
- cin.ignore( numeric_limits<int>::max() , '\n' );
- }
- }while(!(command == "NEWCLIENT" || command == "newclient" || command == "UNMATCH" || command == "unmatch" ||
- command == "PRINTMATCH" || command == "printmatch" || command == "PRINTFREE" || command == "printfree" ||
- command == "QUIT" || command == "quit"));
- // ECHO PRINTING HERE
- }// Closes processing
- void newClient(){
- //Client's Sex
- cout << "Please enter client's sex, F for female, M for male." << endl; // Ask for client's sex
- cin >> clientSex;
- //Client's Name
- cout << "Please enter client's name, no more than 20 characters." << endl; // Ask for client's name
- cin >> clientName;
- //Client's Phone
- cout << "Please enter client's phone number in XXX-XXXX format." << endl; // Ask for client's phone number
- cin >> clientPhone;
- //Client's Number of Interests
- cout << "Please enter number of client's interests (Can have up to 10)." << endl;// Ask for number of interests
- cin >> clientNumInt;
- //Client Interests
- cout << "Please enter client's interests. Place ',' between each (10 characters each) and a '.' after the last one." << endl;
- cin >> clientInterests;
- }// Closes NEWCLIENT
- void unMatch(){
- char unClientName;
- cout << "Please enter the client's name you would like to unmatch." << endl;
- cin >> unClientName;
- }
- void printMatch(){}
- void printFree(){}
- void quitAsking(){}