示例#1
0
/********************************************************************
 *  void Library::addMember()
 *
 *  Purpose: This function prompts the user for member information and
 *           adds a Patron object set with that information to the library.
 *
 *  Preconditions: none
 *
 *  Postconditions: If a unique idNum was entered, the library contains 
 *                  a Patron object with the specified values.
 *******************************************************************/
void Library::addMember()
{
    std::string idNum, name;    // user input
    
    // prompt user for patron ID
    std::cout << "\nEnter the member ID: ";
    std::getline(std::cin, idNum);
    
    // check if ID is already in use
    if (findMember(idNum) >= 0)
    {
        std::cout << "\nThat ID is already in use.\n";
        return;
    }
    
    // prompt user for patron name
    std::cout << "Enter the member name: ";
    std::getline(std::cin, name);
    
    // add patron object to members
    std::cout << "\nAdding " << name << " to records.\n";
    members.push_back(Patron (idNum, name));
}
示例#2
0
 const Library::Transaction& default_transaction()
 {
     static const Library::Transaction tt = Library::Transaction(Book(), Patron(), Chrono::Date());
     return tt;
 }