コード例 #1
0
ファイル: Library.cpp プロジェクト: nathansoz/cs161-final
//Same as above. Uses viewBookInfo to print books checked out to a patron.
void Library::viewPatronInfo(std::string patronID)
{
    Patron* patron = GetPatron(patronID);

    if(patron == NULL)
    {
        std::cout << std::endl << "That patron does not exist!" << std::endl;
    }
    else
    {
        std::cout << std::endl << "Patron ID: " << patron->getIdNum() << std::endl;
        std::cout << "Name: " << patron->getName() << std::endl;
        std::cout << "Fines: $" << std::setprecision(2) << std::fixed << patron->getFineAmount() << std::endl;

        if(patron->getCheckedOutBooks().size() == 0)
        {
            std::cout << "No checked out books." << std::endl << std::endl;
        }
        else
        {
            std::cout << "Checked out books:" << std::endl << std::endl;
            for(int i = 0; i < patron->getCheckedOutBooks().size(); i++)
            {
                viewBookInfo(patron->getCheckedOutBooks().at(i)->getIdCode());
            }
            std::cout << std::endl << std::endl;
        }
    }
}
コード例 #2
0
ファイル: Library.cpp プロジェクト: brownnr/C-and-Cpp
/*******************************************************
**incrementCurrentDate Description:
**	increment current date; increase each Patron's fines
**		by 10 cents for each overdue Book they have
**		checked out (using amendFine)
**	If a book is checked out on day 0, then on day 1,
**		the patron has had it for 1 day.  On day 21, the
**		patron has had it for 21 days, so it is still not
**		overdue.  On day 22, the book is overdue and
**		fines will be charged.
*******************************************************/
void Library::incrementCurrentDate()
{
	//increment currentDate first//
	currentDate++;

	//loop through Patrons//
	for (unsigned int pIndex = 0; pIndex < members.size(); pIndex++)
	{
		//set local pointer and vector only if the//
		//Patron has at least one Book checked out//
		if (members[pIndex]->getCheckedOutBooks().size() > 0)
		{
			Patron* pPtr = members[pIndex];
			vector<Book*> bVector = pPtr->getCheckedOutBooks();

			//loop through Patron's checkedOut Books//
			for (unsigned int bIndex = 0; bIndex < bVector.size(); bIndex++)
			{
				

				//initiate local variables//
				int date = bVector[bIndex]->getDateCheckedOut();
				int chOutDate = bVector[bIndex]->getCheckOutLength();

				//add fine if Book is overdue//
				if (currentDate > chOutDate + date)
					pPtr->amendFine(.10);
			}
		}
	}
}