Ejemplo n.º 1
0
int
runBankTest() {
    CURL *easyhandle;
    int status;
    char *account_id;

    easyhandle = curl_easy_init();
    if ( !easyhandle ) {
        printf( "Curl Error: Initialization failed\n" );
        return( -1 );
    }

    status = doNewAccount( easyhandle, "Savings", "John", &account_id );

    if ( status < 0 ) {
        free( account_id );
        return status;
    }

    status = doDeposit( easyhandle, account_id, 500.0 );

    if ( status < 0 ) {
        return status;
    }

    status = doBuyBond( easyhandle, account_id, 200.0 );
    free( account_id );

    if ( status < 0 ) {
        return status;
    }

    status = doListAccounts( easyhandle );


    return status;
}
Ejemplo n.º 2
0
task main()
{
		struct Account accountList[NUMACCOUNTS];
		initAccounts(accountList, NUMACCOUNTS);

		string account;
		string cardnum;
		string pin;
		int accountindex;
		bool pinCorrect;

		while (getBatteryCurrent() > 0.02)
		{
			/*
			displayString(0,"Swipe card to Begin");
			do
			{
				cardnum = getCardSwipe();
				accountindex = doesExist(cardnum, accountList);
				displayString(0,"ERROR Card Not Found!!");
			}while (accountindex == -1);
			eraseDisplay();
			do
			{
				pinCorrect = checkPin(accountList);
				displayString(0,"ERROR Incorrect PIN");
			}while (pinCorrect == false);
			wait1Msec(100);
			eraseDisplay();
			wait1Msec(500);*/

			//Selection Menu
			while (getButtonPress(buttonEnter) != 1)
			{
					eraseDisplay();
					displayString(1,"Press center button to close transaction");
					displayString(2,"<----                   ---->");
					displayString(3,"Deposit             Withdraw");
					displayString(4,"     Balance: %f", accountList[accountindex].balance);

					waitForButtonPress();

			    if (getButtonPress(buttonLeft) == 1)
			    {
			    		int amount = doDeposit();
			        accountList[accountindex].balance += amount;
							eraseDisplay();
			        displayString(0,"%d", amount);
			    }
			    else if (getButtonPress(buttonRight) ==1)
			    {
			            int amount = doWithdraw(accountList[accountindex]);
			            if (amount != -1)
			            {
			            	accountList[accountindex].balance -= amount;
			            }
			    }
		  }

	    wait1Msec(5000);


		}
}