当前位置: 首页>>代码示例>>C++>>正文


C++ Patron::removeBook方法代码示例

本文整理汇总了C++中Patron::removeBook方法的典型用法代码示例。如果您正苦于以下问题:C++ Patron::removeBook方法的具体用法?C++ Patron::removeBook怎么用?C++ Patron::removeBook使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Patron的用法示例。


在下文中一共展示了Patron::removeBook方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: returnBook

/*******************************************************
**returnBook Description:
**	if the specified Book is not in the Library, return
**		"book not found"
**	if the Book is not checked out, return "book already
**		in library"
**	update the Patron's checkedOutBooks; update the
**		Book's location depending on whether another
**		Patron has requested it; update the Book's
**		checkedOutBy; return "return successful"
*******************************************************/
string Library::returnBook(std::string bID)
{
	//find if Book exists//
	if (getBook(bID) == NULL)
		return "Book was not found.";
	
	//find if Book //
	if (getBook(bID)->getLocation() != CHECKED_OUT)
		return "Book is already in Library.";
	else
	{
		//initiate local pointers if Book exists and is not CHECKED_OUT//
		Book* bPtr = getBook(bID);
		Patron* pPtr = bPtr->getCheckedOutBy();

		//remove Book from Patron's checkOutBooks//
		pPtr->removeBook(bPtr);

		//set Book's location based on request status//
		if (bPtr->getRequestedBy() == NULL)
			bPtr->setLocation(ON_SHELF);
		else
			bPtr->setLocation(ON_HOLD_SHELF);

		//set Book's checkedOutBy//
		bPtr->setCheckedOutBy(NULL);

		//return was successful//
		return "Return successful.";
	}
}
开发者ID:brownnr,项目名称:C-and-Cpp,代码行数:42,代码来源:Library.cpp

示例2: returnBook

//Return a book, if it is not already on the shelf.
void Library::returnBook(std::string bookID)
{
    Book* book = GetBook(bookID);
    
    if(book == NULL)
    {
        std::cout << std::endl << "No such book in holdings." << std::endl << std::endl;
        return;
    }
    if(book->getLocation() == ON_SHELF)
    {
        std::cout << "This book is already on the shelf." << std::endl;
    }
    else if(book->getLocation() == ON_HOLD)
    {
        std::cout << "This book is on the hold shelf and cannot be returned." << std::endl;
    }
    else
    {
        Patron* patron = book->getCheckedOutBy();

        if(book->getRequestedBy() == NULL)
        {
            book->setLocation(ON_SHELF);
            book->setCheckedOutBy(NULL);
            book->setDateCheckedOut(-1);
            patron->removeBook(book);
        }
        else
        {
            book->setLocation(ON_HOLD);
            book->setCheckedOutBy(NULL);
            book->setDateCheckedOut(-1);
            patron->removeBook(book);
        }
    }
}
开发者ID:nathansoz,项目名称:cs161-final,代码行数:38,代码来源:Library.cpp


注:本文中的Patron::removeBook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。