Exemple #1
0
/*******************************************************
**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);
			}
		}
	}
}