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


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

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


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

示例1: main

void main()
{
	BankAccount b;
	b.setName("Rana");
	b.setAccount("234");
	b.setBalance(20);
	b.deposite(1024);
	b.deposite(1024);
	cout<<b.getBalance();
	system("pause");


}
开发者ID:RanaSamy,项目名称:Assignment1,代码行数:13,代码来源:Source.cpp

示例2: main

int main()
{
	string symbol;			// company stock symbol
	double val;				
	double cashBal;			// variable for cashBalance
	int choice;				// user choice	
	const int def = 10000;	// default cashBalance value
	int numOfShares;		// stock number of shares
	double maxPrice;		// max price user is willing to pay to buy stock
	double minPrice;			// min price user is willing to pay to sell stock
	double totalBal;

	BankAccount ba;		// create object of class BankAccount
	double am;			// declare amount variable which will be used by class BankAccount

	StockPortfolioAccount spa;		// create object of class Stock Portfolio Account

	DoublyLinkedList dll;			// create  dll

	time_t t;			// create a time_t object
	struct tm  buf;		// create a tm object which stores all the calendar information


	//------------------------ Step 1 - load the stock text file data into hash table-----------------------------


	loadFile();


	// -----------------------Step 2 - Load the cashBalance value from .txt file-----------------------------------
	{	// start of block statement

		ifstream inCash("cash_balance.txt");						// create ifstream object
		ofstream cas;

		if (inCash.good())	// if file exists
		{
			//inCash.open("cash_balance.txt", ios::in);		// open the file
			getline(inCash, line);					// get the line
			stringstream ss(line);					// store it in stringstream
			ss >> cashBal;							// retireve the cashBalance
			ba.setBalance(cashBal);					// set the cashBalance
			inCash.close();
		}
		// if file is not created then create a new cash_balance.txt file and store 10000
		else
		{
开发者ID:aadityashukla1,项目名称:Stock-and-Bank-Account-Management-System,代码行数:47,代码来源:main_aaditya.cpp

示例3: mainMenu

void mainMenu()
{
    int mainChoice; // choice for top menu
    
	// stockaccount object
	StockAccount stockObj;
	// bankaccount object
	BankAccount bankObj;

	// link two balance
	bankObj.setBalance(stockObj.getBalance());

    do {
        instructionTop();
        cin >> mainChoice;
		while (cin.fail()){
			cout << "\nPlease enter an integer value: ";
			cin.clear();
			cin.ignore();
			cin >> mainChoice;
		}

        switch ( mainChoice ) {
            case 1:
            {
                // stock menu
                cout << "\nStock Portfolio Account" << endl;

				// update balance
				stockObj.setBalance(bankObj.getBalance());

                int stockChoice; // choice for stock menu
                
                string stockSymbol; // stock symbol
                int numberShare; // number of shares
                double maxPrice; // max price to buy shares
                double minPrice; // min Price to sell shares
				string time_start, time_end; // time period to view graph
                
                do {
                    stockInstruction();
                    cin >> stockChoice;

					while (cin.fail()){
						cout << "\nPlease enter an integer value: ";
						cin.clear();
						cin.ignore();
						cin >> stockChoice;
					}

                    //StockAccount *stockPtr = &account;
                    
                    switch ( stockChoice ) {
                        case 1:
                            // display price for stock
                            cout << "\nPlease enter the stock symbol: ";
                            cin >> stockSymbol;
                            stockObj.displayPrice( stockSymbol ); // WORKING ON IT
                            break;
                        case 2:
                            // display current portfolio
                            //cout << "display current portfolio" << endl;
							stockObj.displayPortfolio();
                            break;
                        case 3:
                            // buy shares
                            cout << "Please enter the stock symbol you wish to purchase: ";
                            cin >> stockSymbol;
							
                            cout << "Please enter the number of shares: ";
                            cin >> numberShare;
							while (cin.fail()){
								cout << "\nPlease enter an integer value: ";
								cin.clear();
								cin.ignore();
								cin >> numberShare;
							}

                            cout << "Please enter the maximum amount you are willing to pay per share: $";
                            cin >> maxPrice;
							while (cin.fail()){
								cout << "\nPlease enter a double value: $";
								cin.clear();
								cin.ignore();
								cin >> maxPrice;
							}

							stockObj.buyStock(&Node(stockSymbol, numberShare), maxPrice);
                            
                            break;
                        case 4:
                            // sell shares
                            cout << "Please enter the stock symbol you wish to sell: ";
                            cin >> stockSymbol;
                            cout << "Please enter the number of shares: ";
                            cin >> numberShare;

							while (cin.fail()){
								cout << "\nPlease enter an integer value: ";
								cin.clear();
//.........这里部分代码省略.........
开发者ID:LishengZhou,项目名称:AccountManagementSystem,代码行数:101,代码来源:Main_zhou.cpp


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