CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: dating program

  1. #1
    Join Date
    Apr 2009
    Posts
    1

    Exclamation dating program

    so basically im lost i tryed following the teachers notes and i cant get it to work the dating.cpp is mine the other three files are what the teacher gave us to use if anyone could help i would be greatful








    this is dating.cpp
    /*Input: The program will read the input from stard input. The program will crea!

    the other of females, then match the individuals according to their interests.

    Output: All written output goes to standard output. The program prompts a lis!

    the corresponding commands output.

    Preconditions: The list must have all of the required fields. All input must !

    Postconditions:

    */

    #include <iostream>
    using namespace std;
    #include <fstream>
    #include <string>
    #include "ListA.cpp"
    const int MALE = 0 ;
    const int FEMALE = 1 ;
    int genderID = 0;
    ifstream clientLists ("clients.txt") ;
    int matchLoc = 0 ;
    /*


    Function name: NEWCLIENT
    Input: the new clients information
    Preconditions: Trys to find a female match when entered
    Postconditions: Must print out new client and match or no match
    CallersoCommands
    Callees:

    */
    void getNextClient( ListItemType clientLists , ifstream & comndFile)
    {

    }

    /*
    Function name: UNMATCH
    Input: The last and first name of client
    Output: The two matches "current match" fields are set to zero
    Preconditions: Must have <last name> <first name>
    Postconitions: Changes both matches
    Callers: doCommands
    Callees:
    */
    clientRecType item ;
    void getMainData ( clientRecType & item , char & gender , ifstream inFile)
    {

    inFile >> gender ;
    cout << gender ;
    inFile >> item.lastName ;
    cout << item.lastName ;
    inFile >> item.firstName ;
    cout << item.firstName ;
    inFile >> item.phoneNum ;
    cout << item.phoneNum ;
    inFile >> item.numIntrs ;
    cout << item.numIntrs ;
    int j = 0 ;
    int numIntrs = item.numIntrs ;
    for ( j=0;j<=numIntrs;j++) {
    inFile >> item.interest[j] ;
    cout << item.interest[j] ;
    }
    inFile >> item.matchLoc ;
    cout << item.matchLoc ;
    }

    void putClientInList(clientRecType & item , char gender , ListItemType & clientLists) {
    int which = 0 ;
    int pos ;
    char M ;
    char F ;
    if (gender == M) which = MALE ;
    else which = FEMALE ;
    clientLists[which] insert(pos,item, success) ;
    pos = clientLists[which].getLength() + 1 ;
    clientRecType client ;
    clientRecType candidate ;
    }
    void isMatch (clientRecType client, clientRecType candidate){
    bool result ;
    if (candidate.matchLoc != 0) result=false ;
    else{
    int numMatchs = 0 ;
    int j ;
    for (j = 0;j<=numIntrs - 1;j++){
    if (client.interest= candidate.interest)numMatchs++ ;
    }
    if (numMatchs>=3) result=true;
    }


    }

    void makeMatch( ListItemType clientLists, int genderID, int matchLoc, int oppLoc){
    int client ;
    int oppClient ;
    int oppID =( 1 - genderID) ;


    }

    void doMatch( ListItemType clientLists , int genderID , int pos , int numOpp) {


    int oppSex = (1 - genderID) ;
    numOpp = clientLists[oppSex].getLength() ;
    int posFound = 0 ;
    for ( pos=1; pos<=clientLists[oppSex].getLength();pos++){

    }

    if (posFound !=0) makeMatch();
    else if(posFound=0) cout << "no match" ;
    }
    void unMatch()
    {
    cout <<"last and first name are entered, if paired their match number ";

    }
    /*
    Function name: PRINTMATCH
    Input: list of paired clients
    Output: prints out paired clients
    Preconditions: prints only paired clients
    Postconditions: non
    Callers: doCommands
    Callees:
    */

    void printMatch()
    {
    cout <<"reads lists and finds clients with client match > 0 and prints";


    }

    /*
    Function name: PRINTFREE
    Input: list of clients
    Output: prints list of clients who aren't matched
    Preconditions: prints full name and phone numbers
    Postconditions: non
    Callers: doCommands
    Callee:

    */

    void printFree(ListItemType clientList)
    {
    int pos ;
    int oppSex = genderID - 1;
    for ( pos=1; pos<=clientLists[oppSex].getLength();pos++){
    cout << clientList[oppSex];
    }



    }

    /*
    Function name: QUIT
    Input: quit
    output: prints out quit and then "Have a good day."
    Preconditions: none
    Postconditions: none
    Callers: doCommands
    Callees: none

    */

    void quit()
    {
    cout <<"received QUIT command, exiting. Have a good day. then ends program" ;

    }
    /* function name: DOCOMMANDS
    Input: select command from menu
    Output: prints out the command selected and the output of that command
    Preconditions: must select specific command or else it reasks
    Postconditions: none
    Callers: main
    Callees: commands

    */

    void doCommands()
    {
    if (inFile = "PUTCLIENTINLIST") putClientInList();
    else if(inFile = "UNMATCH") unMatch();
    else if(inFile = "PRINTMATCH") printMatch();
    else if(inFile = "PRINTFREE") printFree();
    else if(inFile = "QUIT") quit();
    }
    void getNextClient( clientRecType & item , char & gender , ifstream inFile){



    }

    void dumpLists()
    {
    cout << "puts the lists into two lists male and female" << endl;
    }

    void buildLists()
    {

    }

    int main(){

    cout << "hi" << endl;
    buildLists();
    doCommands();
    dumpLists();
    quit();
    printFree(ListItemType clientList);
    printMatch();
    unMatch();

    }








    this is LISTA.cpp
    // *********************************************************
    // Implementation file ListA.cpp for the ADT list
    // Array-based implementation
    // *********************************************************
    #include "ListA.h" //header file

    List::List() : size(0)
    {
    } // end default constructor

    bool List::isEmpty() const
    {
    return size == 0;
    } // end isEmpty

    int List::getLength() const
    {
    return size;
    } // end getLength

    void List::insert(int index, ListItemType newItem,
    bool& success)
    {
    success = (index >= 1) &&
    (index <= size + 1) &&
    (size < MAX_LIST);
    if (success)
    { // make room for new item by shifting all items at
    // positions >= index toward the end of the
    // list (no shift if index == size+1)
    for (int pos = size; pos >= index; --pos)
    items[translate(pos+1)] = items[translate(pos)];
    // insert new item
    items[translate(index)] = newItem;
    ++size; // increase the size of the list by one
    } // end if
    } // end insert

    void List::remove(int index, bool& success)
    {
    success = (index >= 1) && (index <= size) ;
    if (success)
    { // delete item by shifting all items at positions >
    // index toward the beginning of the list
    // (no shift if index == size)
    for (int fromPosition = index+1;
    fromPosition <= size; ++fromPosition)
    items[translate(fromPosition-1)] = items[translate(fromPosition)];
    --size; // decrease the size of the list by one
    } // end if

    } // end remove

    void List::retrieve(int index, ListItemType& dataItem,
    bool& success) const
    {
    success = bool( (index >= 1) && (index <= size) );
    if (success)
    dataItem = items[translate(index)];
    } // end retrieve

    int List::translate(int index) const
    {
    return index-1;
    } // end translate
    // End of implementation file.




    THIS IS LIST.h

    // *********************************************************
    // Header file ListA.h for the ADT list
    // Array-based implementation
    // *********************************************************
    #include "clientRec.h"

    const int MAX_LIST = 100 ;
    typedef clientRecType ListItemType;

    class List
    {
    public:

    List(); // default constructor
    // destructor is supplied by compiler

    // list operations:
    bool isEmpty() const;
    // Determines whether a list is empty.
    // Precondition: None.
    // Postcondition: Returns true if the list is empty;
    // otherwise returns false.

    int getLength() const;
    // Determines the length of a list.
    // Precondition: None.
    // Postcondition: Returns the number of items
    // that are currently in the list.

    void insert(int index, ListItemType newItem,
    bool& success);
    // Inserts an item into the list at position index.
    // Precondition: index indicates the position at which
    // the item should be inserted in the list.
    // Postcondition: If insertion is successful, newItem is
    // at position index in the list, and other items are
    // renumbered accordingly, and success is true;
    // otherwise success is false.
    // Note: Insertion will not be successful if
    // index < 1 or index > getLength()+1.

    void remove(int index, bool& success);
    // Deletes an item from the list at a given position.
    // Precondition: index indicates where the deletion
    // should occur.
    // Postcondition: If 1 <= index <= getLength(),
    // the item at position index in the list is
    // deleted, other items are renumbered accordingly,
    // and success is true; otherwise success is false.

    void retrieve(int index, ListItemType& dataItem,
    bool& success) const;
    // Retrieves a list item by position.
    // Precondition: index is the number of the item to
    // be retrieved.
    // Postcondition: If 1 <= index <= getLength(),
    // dataItem is the value of the desired item and
    // success is true; otherwise success is false.

    private:

    ListItemType items[MAX_LIST]; // array of list items
    int size; // number of items in list

    int translate(int index) const;
    // Converts the position of an item in a list to the
    // correct index within its array representation.
    }; // end List class
    // End of header file.




    THIS IS CLIENTREC.h
    #include <iostream>
    #include <string>

    using namespace std ;

    #ifndef CLIENTREC_H
    #define CLIENTREC_H

    #define MAX_INTRS 10

    struct clientRecType
    {
    string lastName ;
    string firstName ;
    string phoneNum ;

    /* number of interests -- up to MAX_INTRS */

    int numIntrs ;

    /* storage for the interests */

    string interest[MAX_INTRS] ;

    /* location of this person's match
    in the other list, or zero */

    int matchLoc ;
    } ;

    #endif
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: dating program

    1. Please use code tags.
    2. Please tell us the exact problem.
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured