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


C++ BankAccount::View_balance方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
					PortfolioList.SortLinkedList();												//sort the Linked List
					PortfolioList.printList();													//print the Linked List

					break;
				case 3:

					flag1=stock.buy_shares(company_name,price_per_share);						//buy shares
					already_in_list=stock.alreadyInList(account_sym,account_index);				//check to see if the stock is already in list

					if(flag1)																	//if transaction went through
					{
						type="Buy";
						if(already_in_list)														//if in list
						{
							stock.update_account_information(account_sym,account_num,account_price,account_total,account_index); //just update the list(no new entry)
						}
						else																	//if it's not in the list
						{
							stock.store_account_information(stock);								//store the stock in account information
						}
					}
					stock.store_transaction(stock,type);												//store tranaction in file
					break;	
				case 4:
					flag2=stock.sell_shares(account_sym,account_price);						//sell shares
					already_in_list=stock.alreadyInList(account_sym,account_index);			//check to see if the stock is already in list

					if(flag2)																//if transaction went through
					{
						type="Sell";
						stock.update_sell_information(account_sym,account_num,account_price,account_total,account_index); //just update the list
					}
					stock.store_transaction(stock,type);												//store tranaction in file
					break;

				case 5:
					stock.read_transaction_history(trans_type,trans_sym, trans_num, trans_price,trans_total, trans_time);
					cout<<"Event"<<setw(15)<<"Company Symbol"<<setw(9)<<"Number"<<setw(19)<<"Price per share"<<setw(15)<<"Total value"<<setw(11)<<"Time\n";
					while(trans_sym[m]!="END")
					{
						cout<<trans_type[m]<<setw(7)<<trans_sym[m]<<setw(15)<<trans_num[m]<<setw(15)<<trans_price[m]<<setw(19)<<trans_total[m]<<setw(18)<<trans_time[m]<<endl;
						m++;
					}
					m=0;
					cout<<"\n";
					break;
				default:
					cout<<"You entered an invalid number!"<<endl;
					break;
				}
			}
			break;
		case 2:
				//Bank Account
			cout<<"\n\nBank Account"<<endl;
			while(1)
			{
				cout<<"Please select an option:"<<endl
					<<"1. View account balance"<<endl
					<<"2. Deposit Money"<<endl
					<<"3. Withdraw Money"<<endl
					<<"4. Print out history"<<endl
					<<"5. Return to previous menu"<<endl;

				cin>>option;
				if(option==5)																	//return to previous menu
					break;
				switch(option)
				{
				case 1:
					myAccount.View_balance();													//View Balance
					break;
				case 2:
					cout<<"Please enter the amount: "<<endl;
					cin>>myAmount;
					myAccount.Deposit(myAmount);
					break;
				case 3:
					cout<<"Please enter the amount: "<<endl;
					cin>>myAmount;
					myAccount.Withdraw(myAmount);
					break;
				case 4:
					myAccount.Print_history();
					break;
				default:
					cout<<"You entered an invalid number!"<<endl;
					break;
				}
			}
			break;
		case 3:												//exit the program
			exit(0);
		default:
			break;
		}
	}

	return 0;
}
开发者ID:mhdslm,项目名称:CPlusPlus-Projects,代码行数:101,代码来源:Main_Mahrad.cpp


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