本文整理汇总了C++中Customer::setKey方法的典型用法代码示例。如果您正苦于以下问题:C++ Customer::setKey方法的具体用法?C++ Customer::setKey怎么用?C++ Customer::setKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::setKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processTransactions
//-----------------------------------------------------------------------------
// processTransactions(ifstream& infile) const
// Process a list of transactions from an input file
//-----------------------------------------------------------------------------
void MovieStore::processTransactions(ifstream& infile)
{
while (true)
{
if (infile.eof() || !infile.good())
{
break;
}
char c;
infile >> c;
string key;
stringstream ss;
Customer target;
switch (c)
{
// borrow and return
case 'B':
case 'R':
int custId;
char format;
char genre;
char sz[256];
Customer* pCust;
Movie* pMovie;
infile >> custId >> format >> genre;
infile.get();
infile.get(sz, ARRAYSIZE(sz));
key = sz;
ss << custId;
target.setKey(ss.str());
// Clean up
infile.clear();
infile.ignore(numeric_limits<streamsize>::max(), '\n');
// Validate genre
if (!m_movieManager.isValidGenre(genre))
{
cerr << "Invalid genre '" << genre << "'" << endl;
continue;
}
// Retrieve customer
pCust = dynamic_cast<Customer*>(m_customersHash.retrieve(target));
// Retrieve movie
pMovie = m_movieManager.find(genre, key);
// Validate customer
if (NULL == pCust)
{
cerr << "Customer '" << custId << "' not found" << endl;
continue;
}
// Validate movie
else if (NULL == pMovie)
{
cerr << "Movie with key '" << key << "' not found" << endl;
continue;
}
// Validate checkout
else if (! toggleCheckoutState(('B' == c), pMovie, custId, format))
{
continue;
}
else
{
// Add transaction record to customer
Transaction* pTrans = new Transaction(pMovie, c, format);
pCust->addTransaction(pTrans);
}
break;
// show movie inventory
case 'S':
m_movieManager.print();
break;
// Display transaction history by customer
case 'H':
cout << m_customers;
break;
default:
cout << "Invalid transaction code " << c << endl;
// Clean up
infile.clear();
infile.ignore(numeric_limits<streamsize>::max(), '\n');
break;
//.........这里部分代码省略.........