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


C++ Worker::ProcessTransaction方法代码示例

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


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

示例1: OpenForBusiness

/* The key function for the program. All course of the program is controlled by this function*/
void Bank::OpenForBusiness(Bank our_bank) {
	
	Worker Bob = Worker();
	bool readin = Bob.ReadFromFile(&our_bank); //returns true if items were read in from the file.

	if (readin) {
		cout <<"Welcome back to our bank!" << endl;
	} else {
		cout <<"Wow, a new customer! Welcome to our bank!" << endl;
	}
	restart:
	cout <<"What would you like to do?\n";
	cout <<"	1.Perform a transaction.\n";
	cout <<"	2.Access account records.\n";
	cout <<"	3.Exit.\n";
	
	string choice;
	
	cin >> choice;

	/*PERFORM TRANSACTION*/
	if (choice == "1") {
		bool more_trans = true;

		while (more_trans)	{
			int user_response[2];	//updated in the function via pointers
			Bob.GetTransaction(our_bank, user_response);

			more_trans = Bob.ProcessTransaction(user_response, &our_bank); // returns false if the user is done entering transactions, true otherwise.
		}
		goto restart;
		/*ACCESS ACCOUNT RECORDS*/
	}else if (choice == "2") {
		
		bool more_prints = true;
		while (more_prints)	{
			cout << "Would you like to view an account's transaction history?Y/N\n";
			string resp;
	
			bool badinputchk = true;
	
			while (badinputchk) { //false if we have good input.
			cin >> resp;
				if (resp == "Y") {
					

					string resp2;
					cout << "Which account would you like to view (1,2,3...)? Enter 'all' to view all of them.\n";
					cin.clear();
					cin >> resp2;
				
					tryagain:	//return here if we don't get a valid input

					if (resp2 == "all")	{
						for (int i=1;i<21;i++)	//print all the account transactions					
							PrintAccntInfo(i,our_bank);
							badinputchk = false;
					} else if (atoi(resp2.c_str())) { // if a single account is entered
						int resp_int = stoi(resp2);
						PrintAccntInfo(resp_int,our_bank);
						badinputchk = false;
					
					} else { //if resp is not a valid int
						cout << "Please enter a valid account number (1-20).\n";
						cin.clear();
						cin >> resp2;
						goto tryagain;
					}

				} else if (resp == "N") {
					more_prints = false;
					goto restart;
				} else {
					cin.clear();
					cout << "Please enter either 'Y' or 'N'.\n";
				}
			} //end badinputchk while
开发者ID:AdamBJ,项目名称:ZJU-OO-Design-Course,代码行数:78,代码来源:Bank.cpp


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