本文整理汇总了C++中Transaction::create方法的典型用法代码示例。如果您正苦于以下问题:C++ Transaction::create方法的具体用法?C++ Transaction::create怎么用?C++ Transaction::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction::create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
if (argc == 4) {
Transaction* session = new Transaction(argv[1], argv[2], argv[3]);
string input, username, type, event, seller, balance, price;
int ticketNum;
while (getline(cin, input)) {
//cout << "Enter your command." << endl;
//input = rtrim(input);
input = Poco::trimRight(input);
if (!session->isLoggedIn()) {
if (input.compare(LOGIN) == 0) {
// Log in stuff.
cout << ENTER_USERNAME << endl;
getline(cin, input);
if (!validUsername(input)) {
cout << INVALID_USERNAME_EXIST << endl;
}
else if (session->login(input)) {
cout << LOGIN_SUCCESS << endl;
}
}
else if (input.compare(QUIT) == 0) {
session->quit();
break;
}
else if (input.compare(LOGOUT) == 0
|| input.compare(BUY) == 0
|| input.compare(CREATE) == 0
|| input.compare(SELL) == 0
|| input.compare(REFUND) == 0
|| input.compare(ADDCREDIT) == 0
|| input.compare(DELETE) == 0) {
cout << USER_NOT_LOGGED_IN << endl;
}
else {
cout << INVALID_COMMAND << endl;
}
}
else if (input.compare(LOGIN) == 0) {
cout << USER_ALREADY_LOGGED << endl;
}
else if (input.compare(LOGOUT) == 0) {
session->logout();
cout << LOGOUT_SUCCESS << endl;
}
else if (input.compare(CREATE) == 0) {
cout << CREATE_ENTER_USERNAME << endl;
getline(cin, username);
if (!validUsername(username)) {
cout << INVALID_USERNAME << endl;
}
else {
cout << ENTER_ACCOUNT_TYPE << endl;
getline(cin, type);
if (!validAccountType(type)) {
cout << INVALID_ACCOUNT_TYPE << endl;
}
else {
cout << ENTER_ACCOUT_BALANCE << endl;
getline(cin, balance);
//cin >> balance;
if (!validBalance(balance)) {
cout << INVALID_ACCOUNT_BALANCE << endl;
}
else {
double validBalance;
Poco::DynamicAny(balance).convert(validBalance);
if (session->create(username, type, validBalance)) {
cout << CREATE_SUCCESS << endl;
}
}
}
}
}
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);
//.........这里部分代码省略.........