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


C++ Patron类代码示例

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


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

示例1: incrementCurrentDate

/*******************************************************
**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);
			}
		}
	}
}
开发者ID:brownnr,项目名称:C-and-Cpp,代码行数:42,代码来源:Library.cpp

示例2: incrementCurrentDate

/*********************************************************************
 ** Description:
 ** applies 10 cent fine to each overdue book by patron per pay
 *********************************************************************/
void Library::incrementCurrentDate()
{
    int update;
    Patron* checkOut;
    string patID;
    double fineAMT;
    
    
    fineAMT = .10;
    
    for( int i = 0; i < holdings.size(); i++)
    {
        if(holdings[i]->getLocation() != 0)
        {
            update = holdings[i]->getDateCheckedOut() + 1;
            holdings[i]->setDateCheckedOut(update);
            if((holdings[i]->getDateCheckedOut() - currentDate) > 21)
            {
                // fine applied.
                checkOut = holdings[i]->getCheckedOutBy();
                patID = checkOut->getIdNum();
                members[i]->amendFine(fineAMT);
                
            }
        }
    }
    
    currentDate++;
    
    cout << "The new date is " << currentDate;
}
开发者ID:alaquitara,项目名称:cs161,代码行数:35,代码来源:Library.cpp

示例3: while

/*
---------------------------------buildPatrons--------------------------------
buildPatrons - creates patrons from the data file and hands them to the
               library to appropriately manage.

PreConditions: File must be in the valid format, defined for Assignment #3.
PostConditions: Every line is read, processed, and each patron generated from
                the process is handed to the library to insert into the 
                data structures.
*/
void Manager::buildPatrons() {
    int inputID = -1;
    std::string inputName;

    //While we have stuff to process from the data file...
    while(!patronsStream.eof()) {
        inputID = -1;
        patronsStream >> inputID;

        //Is the Patron ID valid?
        if(inputID >= 0 && inputID < MAX_PATRON_SIZE) {
            
            //Yes!  Let's process the input data and add them to the patron
            //data structure.
            patronsStream.get();
            getline(patronsStream, inputName);
            Patron* inputPatron = new Patron();
            inputPatron->setName(inputName);
            inputPatron->setID(inputID);
            bool inserted = MyLibrary.insert(inputPatron);
            
            //delete inputPatron if we are unable to insert them
            if(inserted == false) {
                delete inputPatron;
            }

            inputPatron = NULL;
            inputID = -1;
        //Patron ID is invalid, so we throw away the rest of the line.
        } else {
            getline(patronsStream, inputName);
        }
    }
    patronsStream.close();
}
开发者ID:patkaehuaea,项目名称:UWBothell_CSS502_AS3,代码行数:45,代码来源:manager.cpp

示例4: getBook

/*******************************************************
**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

示例5: getPatron

/*********************************************************************
 ** Description:
 ** returns a pointer to a memeber pased off their ID
 *********************************************************************/
Patron* Library:: getPatron(std::string pID)
{
    Patron* patron;
    if(checkMember(pID)!=true)
    {
        for(int i = 0; i <  members.size(); i++)
        {
            if(members[i]->getIdNum() == pID)
            {
                cout << "Name : " << members[i]->getName() << endl;
                cout << "ID : " << members[i]->getIdNum() << endl;
                //Set the dollar format
                cout << "Fines $" << members[i]->getFineAmount() << endl;
                
                //checkouted books
                cout << "Books Checked Out" << endl;
                for( int j = 0; j < holdings.size(); j++)
                {
                    patron = holdings[j]->getCheckedOutBy();
                    if(pID == patron->getIdNum())
                    {
                        cout << "Book Name " << holdings[j]->getTitle() << endl;
                    }
                }
            }
        }
    }
    else
    {
        cout << "Patron not in system" << endl;
    }
    return 0;
}
开发者ID:alaquitara,项目名称:cs161,代码行数:37,代码来源:Library.cpp

示例6: if

void Restaurant::initializeAdmixtureProportions(void) {

	// set up vectors for admixture
	if (assumingAdmixture == true && assumingDpp == false)
		{
		// what type of prior are we placing on the mixing proportions?
		if (settingsPtr->getAdmixtureDist() == "fixed")
			admixtureVarianceParm = settingsPtr->getAdmixtureParm1();
		else if (settingsPtr->getAdmixtureDist() == "exponential")
			admixtureVarianceParm = ranPtr->exponentialRv( settingsPtr->getAdmixtureParm1() );
		else if (settingsPtr->getAdmixtureDist() == "uniform")
			admixtureVarianceParm = ranPtr->uniformRv( settingsPtr->getAdmixtureParm1(), settingsPtr->getAdmixtureParm2() );
		else if (settingsPtr->getAdmixtureDist() == "gamma")
			admixtureVarianceParm = ranPtr->gammaRv( settingsPtr->getAdmixtureParm1(), settingsPtr->getAdmixtureParm2() );
			
		// get the upper and lower limits for the admixture variance parameter
		if (settingsPtr->getAdmixtureDist() == "uniform")
			{
			admixtureLowerLimit = settingsPtr->getAdmixtureParm1();
			admixtureUpperLimit = settingsPtr->getAdmixtureParm2();
			}
		else if (settingsPtr->getAdmixtureDist() == "exponential")
			{
			admixtureLowerLimit = 0.001;
			admixtureUpperLimit = ( 1.0 / settingsPtr->getAdmixtureParm1() ) * 100.0;
			}
		else if (settingsPtr->getAdmixtureDist() == "gamma")
			{
			admixtureLowerLimit = 0.001;
			admixtureUpperLimit = ( settingsPtr->getAdmixtureParm1() / settingsPtr->getAdmixtureParm2() ) * 100.0;
			}
			
		// initialize the counts and probabilities for the mixing proportions
		popCounts = new MbVector<int>[observationsPtr->getNumIndividuals()];
		popProbs  = new MbVector<double>[observationsPtr->getNumIndividuals()];
		for (int i=0; i<observationsPtr->getNumIndividuals(); i++)
			{
			popCounts[i] = MbVector<int>(modelPtr->getNumPopulations());
			popProbs[i] = MbVector<double>(modelPtr->getNumPopulations());
			MbVector<double> alp( modelPtr->getNumPopulations() );
			for (int j=0; j<modelPtr->getNumPopulations(); j++)
				alp[j] = admixtureVarianceParm / modelPtr->getNumPopulations();
			ranPtr->dirichletRv(alp, popProbs[i]);
			for (int j=0; j<modelPtr->getNumPopulations(); j++)
				popCounts[i][j] = 0;
			}
		
		for (int i=0; i<getNumTables(); i++)
			{
			Table *tp = getTable(i);
			for (int j=0; j<tp->getNumPatrons(); j++)
				{
				Patron *p = tp->getPatron(j);
				popCounts[ p->getIndividual() ][ i ]++;
				}
			}
			
		}
}
开发者ID:goshng,项目名称:cocoa,代码行数:59,代码来源:model.cpp

示例7: TEST_F

TEST_F(PatronTest, CreateDefaultsAllFields)
{
    Patron nobody;

	ASSERT_THAT(nobody.Name(), Eq(""));
	ASSERT_THAT(nobody.Id(), Eq(0));
	ASSERT_THAT(nobody.FineBalance(), Eq(0));
}
开发者ID:ChiahungTai,项目名称:TDD,代码行数:8,代码来源:PatronTest.cpp

示例8: requestBook

/*********************************************************************
 ** Description:
 ** Allows a patron to request a book not on shelf based off enums
 *********************************************************************/
string Library::requestBook(string patronID, string bookID)
{
    Patron* patID;
    
    if(checkBook(bookID) != true)
    {
        for( int i = 0; i < holdings.size(); i++)
        {
            //Puts book on hold
            if(holdings[i]->getIdCode() == bookID)
            {
                // if currently on shelf
                if(holdings[i]->getLocation() == 0)
                {
                    holdings[i]->setLocation(ON_HOLD_SHELF);
                    //Connects Hold to a Patron
                    for(int j = 0; j < members.size(); j++)
                    {
                        if(members[j]->getIdNum() == patronID)
                        {
                            holdings[i]->setRequestedBy(members[j]);
                            cout << holdings[i]->getTitle() << " is now on hold for "
                            << members[j]->getName() << endl;
                        }
                    }
                }
                // if currently on hold
                else if(holdings[i]->getLocation() == 1)
                {
                    cout << "Already on hold by " << holdings[i]->getRequestedBy() << endl;
                }
                else
                {
                    for(int j = 0; j < members.size(); j++)
                    {
                        //if person already has book checked out
                        patID = holdings[i]->getCheckedOutBy();
                        if(patID->getIdNum() == patronID)
                        {
                            cout << "Already checked out by " << (holdings[i])->getRequestedBy() << endl;
                        }
                        else
                        {
                            holdings[i]->setRequestedBy(members[j]);
                            cout << holdings[i]->getTitle() << " is now on hold for "
                            << members[j]->getName() << endl;
                        }
                    }
                }
            }
        }
    }
    else
    {
        cout << "book not found" << endl;
    }
    return 0;
}
开发者ID:alaquitara,项目名称:cs161,代码行数:62,代码来源:Library.cpp

示例9: findBook

/********************************************************************
 *  void Library::viewBookInfo(std::string bookID)
 *
 *  Purpose: This function prints the information of the Book object
 *           that matches the specified bookID to the console.
 *
 *  Preconditions: none
 *
 *  Postconditions: The information of the Book object is printed to
 *                  the console window.
 *******************************************************************/
void Library::viewBookInfo(std::string bookID)
{
    // declare variable and set to book index
    int bIndex = findBook(bookID);
    
    // validate bookID
    if (bIndex < 0)
    {
        std::cout << "\nThat book ID was not found in the library database.\n";
        return;
    }
    
    // print book ID, title and author
    std::cout << "\nInformation on book ID " << holdings[bIndex].getIdCode()
              << "\n  Title:    " << holdings[bIndex].getTitle()
              << "\n  Author:   " << holdings[bIndex].getAuthor();
    
    // print book location
    std::cout << "\n  Location: ";
    switch (holdings[bIndex].getLocation())
    {
        case CHECKED_OUT:
            std::cout << "Checked out\n";
            break;
        case ON_HOLD:
            std::cout << "On hold\n";
            break;
        case ON_SHELF:
            std::cout << "On the shelf\n";
    }
    
    std::cout << std::endl;
    
    // print requestedBy if book has been requested
    Patron *pPatron = holdings[bIndex].getRequestedBy();
    if (pPatron != NULL)
        std::cout << "  This book has been requested by "
                  << pPatron->getName() << ".\n";
    
    // print checkedOutBy and due date if book is checked out
    pPatron = holdings[bIndex].getCheckedOutBy();
    if (pPatron != NULL)
    {
        std::cout << "  This book is checked out by "
                  << pPatron->getName() << ".\n";
        
        // get due date and print appropriate message
        int due = holdings[bIndex].getDateCheckedOut() + Book::CHECK_OUT_LENGTH;
        if (due == currentDate)
            std::cout << "  It is due on day " << due << ", which is today.\n";
        else if (due > currentDate)
            std::cout << "  It is due on day " << due << ", "
                      << "which is in " << due - currentDate << " days.\n";
        else
            std::cout << "  It is due on day " << due << ", "
                      << "which was " << currentDate - due << " days ago.\n";
    }
}
开发者ID:rigertd,项目名称:osu_code_share,代码行数:69,代码来源:Library.cpp

示例10: checkin

void checkin(Patron& p, Book& b)
{   /*
     this function receives by reference a patron and book instance
     changes relevant checkout status
     returns nothing
     */
    b.setCheckOutStatus(0);//sets book checkout status
    p.setBorrowedIn(b);//resets array to not include returned book
    p.setNumberBorrowedIn();//reduces borrowed number by 1
}
开发者ID:joshsarath,项目名称:Fall-13-CSC-281-Project-9,代码行数:10,代码来源:main.cpp

示例11: reportCheckout

void reportCheckout(Patron p, Book b, int test)
{   /*receives a patron, book and the test value
     based on test value prints out if book is checked out to patron
     returns nothing
     */
    if (test==1)
        cout<< b.getID()<<" is checked out to "<<p.getID()<<".\n";
    else
        cout<<b.getID()<<" could not be checked out to "<< p.getID()<<".\n";
}
开发者ID:joshsarath,项目名称:Fall-13-CSC-281-Project-9,代码行数:10,代码来源:main.cpp

示例12: TEST_F

TEST_F(HoldingServiceTest, CheckInUpdatesPatronHoldings)
{
    HoldingBarcode barcode(THE_TRIAL_CLASSIFICATION, 1);
    string patronId("p5");
    CheckOut(barcode, branch1, patronId);

    holdingService.CheckIn(barcode.AsString(), *arbitraryDate + date_duration(1), branch2->Id());

    Patron retrieved = FindPatronWithId(patronId);
    ASSERT_THAT(retrieved.Holdings().size(), Eq(0));
}
开发者ID:jlangr,项目名称:c7,代码行数:11,代码来源:HoldingServiceTest.cpp

示例13: TEST_F

TEST_F(PatronAccessTest, FindByNameReturnsChronologicallyFirstMatch)
{
    Patron match1("Langr", 1);
    access.Save(match1);
    Patron mismatch("Long", 2);
    access.Save(mismatch);
    Patron match2("Langr", 3);
    access.Save(match2);

    Patron found = access.FindByName("Langr");

    ASSERT_THAT(found.Id(), Eq(1));
}
开发者ID:jlangr,项目名称:c7,代码行数:13,代码来源:PatronAccessTest.cpp

示例14: check_out_book

void Library::check_out_book(const chrono::Date& d,const Patron& p,Book& b)
{
  if(!book_exists(b) || !patron_exists(p))
    {
      throw std::runtime_error("patron or book doesnt exist");
    }

  if(p.has_fee())
    {
      throw std::runtime_error("patron has a fee: " + p.amount_fees_owed());
    }

  transactions.push_back(Transactions(d,p,b));
  b.check_out();
}
开发者ID:jingar,项目名称:cplusplus,代码行数:15,代码来源:library.cpp

示例15: main

int main() {
  Patron PatronInOut;

  ifstream ifs("Patrons.txt", ifstream::in); 
  if (ifs.is_open()) {

    while (PatronInOut.readPatron(ifs))
      PatronInOut.writePatron(cout) << endl;
 
    // close the file after finish reading.
    ifs.close(); 
  } else {
    cout << "Can't open file." << endl; 
  }
  return 0;
}
开发者ID:JavaZhangYin,项目名称:coding,代码行数:16,代码来源:client.cpp


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