本文整理汇总了C++中Transaction::addcredit方法的典型用法代码示例。如果您正苦于以下问题:C++ Transaction::addcredit方法的具体用法?C++ Transaction::addcredit怎么用?C++ Transaction::addcredit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction::addcredit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
else if (input.compare(DELETE) == 0) {
//if (session->isAdmin()) {
cout << ENTER_USERNAME << endl;
getline(cin, username);
if (!validUsername(username)) {
cout << INVALID_USERNAME << endl;
}
else if (session->removeUser(username)) {
cout << DELETE_SUCCESS << endl;
}
//}
}
else if (input.compare(ADDCREDIT) == 0) {
if (session->isAdmin()) {
cout << ENTER_USERNAME << endl;
getline(cin, username);
if (!validUsername(username)) {
cout << INVALID_USERNAME << endl;
}
//else if (session->getFileIO()->findUser(username) != -1) {
else {
cout << ENTER_CREDIT_AMOUNT << endl;
getline(cin, balance);
//cin >> balance;
if (!validBalance(balance)) {
cout << INVALID_CREDIT_AMOUNT << endl;
}
else {
double validBalance;
Poco::DynamicAny(balance).convert(validBalance);
if (session->addcredit(username, validBalance)) {
//cout << "new balance: $" << session->getFileIO()->getAccountList()->at(session->getCurrentUser()).getBalance() << endl;
cout << ADDCREDIT_SUCCESS << endl;
}
}
}
}
else {
cout << ENTER_CREDIT_AMOUNT << endl;
//getline(cin, balance);
//cin >> balance;
if (getline(cin, balance) && !validBalance(balance)) {
cout << INVALID_CREDIT_AMOUNT << endl;
}
else {
double validBalance;
Poco::DynamicAny(balance).convert(validBalance);
if (session->addcredit(validBalance)) {
//cout << "new balance: $" << session->getFileIO()->getAccountList()->at(session->getCurrentUser()).getBalance() << endl;
cout << ADDCREDIT_SUCCESS << endl;
}
}
}
}
else if (input.compare(SELL) == 0) {
cout << ENTER_EVENT << endl;
getline(cin, event);
if (!validEventName(event)) {
cout << INVALID_EVENT_TITLE << endl;
}
else {
cout << ENTER_PRICE << endl;
getline(cin, price);
//cin >> price;
if (!validPrice(price)) {
cout << INVALID_EVENT_PRICE << endl;
}
else {
double validPrice;
Poco::DynamicAny(price).convert(validPrice);
cout << ENTER_TICKET_NUMBER << endl;
//getline(cin, ticketNum);
cin >> ticketNum;
bool fail = cin.fail();
cin.clear();
// Skip to next line
string dummy;
getline(cin, dummy);
if (fail || !validTicketNumber(ticketNum)) {
cout << INVALID_TICKET_NUMBER << endl;
}
else if (session->sell(event, validPrice, ticketNum)) {
cout << SELL_SUCCESS << endl;
}
}
}
}
else if (input.compare(BUY) == 0) {