// perform transaction; overrides Transaction's pure virtual function void Withdrawal::execute() { bool cashDispensed = false; // cash was not dispensed yet bool transactionCanceled = false; // transaction was not canceled yet // get references to bank database and screen BankDatabase &bankDatabase = getBankDatabase(); Screen &screen = getScreen(); // loop until cash is dispensed or the user cancels do { // obtain the chosen withdrawal amount from the user int selection = displayMenuOfAmounts(); // check whether user chose a withdrawal amount or canceled if ( selection != CANCELED ) { amount = selection; // set amount to the selected dollar amount // get available balance of account involved double availableBalance = 45 bankDatabase.getAvailableBalance( getAccountNumber() ); // check whether the user has enough money in the account if ( amount <= availableBalance ) { // check whether the cash dispenser has enough money if ( cashDispenser.isSufficientCashAvailable( amount ) ) { // update the account involved to reflect withdrawal bankDatabase.debit( getAccountNumber(), amount ); cashDispenser.dispenseCash( amount ); // dispense cash cashDispensed = true; // cash was dispensed // instruct user to take cash screen.displayMessageLine( "\nPlease take your cash from the cash dispenser." ); } // end if else // cash dispenser does not have enough cash screen.displayMessageLine( "\nInsufficient cash available in the ATM." "\n\nPlease choose a smaller amount." ); } // end if else // not enough money available in user's account { screen.displayMessageLine( "\nInsufficient funds in your account." "\n\nPlease choose a smaller amount." ); } // end else } // end if else // user chose cancel menu option { screen.displayMessageLine( "\nCanceling transaction..." ); transactionCanceled = true; // user canceled the transaction } // end else } while ( !cashDispensed && !transactionCanceled ); // end do...while } // end function execute
void TAccount::print() { //Daten des Kunden ausgeben getCustomer()->print(); //Kontospezifische Daten ausgeben cout << "Kontonr.:\t" << getAccountNumber() << "\n"; cout << "Anz. Buchungen:\t" << getBookingsCount() << "\n"; cout << "Kontostand:\t"; getAccountAmount().print(); cout << "\n"; }
// performs transaction; overrides Transaction's pure virtual function void Deposit::execute() { BankDatabase &bankDatabase = getBankDatabase(); // get reference Screen &screen = getScreen(); // get reference amount = promptForDepositAmount(); // get deposit amount from user // check whether user entered a deposit amount or canceled if ( amount != CANCELED ) { // request deposit envelope containing specified amount screen.displayMessage( "\nPlease insert a deposit envelope containing " ); screen.displayDollarAmount( amount ); screen.displayMessageLine( " in the deposit slot." ); // receive deposit envelope bool envelopeReceived = depositSlot.isEnvelopeReceived(); // check whether deposit envelope was received if ( envelopeReceived ) { screen.displayMessageLine( "\nYour envelope has been received." "\nNOTE: The money deposited will not be available until we" "\nverify the amount of any enclosed cash, and any enclosed " "checks clear." ); // credit account to reflect the deposit bankDatabase.credit( getAccountNumber(), amount ); } // end if else // deposit envelope not received { screen.displayMessageLine( "\nYou did not insert an " "envelope, so the ATM has canceled your transaction." ); } // end else } // end if else // user canceled instead of entering amount { screen.displayMessageLine( "\nCanceling transaction..." ); } // end else } // end function execute
void TAccount::printLastMessage(string klasse, string kontenart){ klasse += ":"; cout << std::left << std::setw(25) << klasse << std::setw(20) << kontenart << "(KtoNr. " << getAccountNumber() << ") wird vernichtet!" << endl; }
void TAccount::printAccountStatement() { //Kontoauszug erstellen... TTime t_current; TDate d_current; cout << "Kontoauszug vom " << d_current.toString() << "; " << t_current.toString() << "\n"; cout << "Kontonr.: " << getAccountNumber() << "; BLZ " << getBank()->getBLZ() << "\n"; cout << "Kontoinhaber: " << getCustomer()->getName() << "\n"; std::cout << std::left << std::setw(11) << "Datum" << std::left << std::setw(17) << "| Betrag" << std::left << std::setw(33) << "| Absender / Empfaenger" << std::left << std::setw(14) << "| Buchungstext" << endl; std::cout << setfill('-') << std::left << std::setw(11) << "" << std::left << std::setw(17) << "|" << std::left << std::setw(33) << "|" << std::left << std::setw(14) << "|" << endl; std::cout << setfill(' '); int bookingsAvailable = -1; for (int i = 0; i < getBookingsCount(); i++) { if (getBookings()[i]->getPrinted(this) != 0) { bookingsAvailable = 0; //Kontoauszug... TMoney a = getBookings()[i]->getAmount(); TMoney m = getSignValueFromBookingByAccount(this, getBookings()[i]); double dABS = fabs(m.getAmount()); char negSign = negZeichen(m); TCustomer* sender = (getBookings()[i]->getDepitor()->getCustomer() == getCustomer()) ? getBookings()[i]->getCreditor()->getCustomer() : getBookings()[i]->getDepitor()->getCustomer(); std::cout << std::left << std::setw(9) << std::fixed << setprecision(2) << getBookings()[i]->getDate().toString() << " | " << std::left << std::setw(0) << negSign << std::right << std::setw(9) << dABS << " " << m.getCurrency() << " | " << std::left << std::setw(30) << sender->getName() << " | " << std::left << std::setw(14) << getBookings()[i]->getMemo() << endl; //std::setprecision( 24 ) //Am Ende wurde der Kontoauszug gedruckt //und die Buchung wird gekennzeichnet getBookings()[i]->setPrinted(0, this); } } if (bookingsAvailable == -1){ //Keine Buchungen vorhanden cout << "keine neuen Buchungen vorhanden!\n"; } std::cout << setfill('-') << std::left << std::setw(11) << "" << std::left << std::setw(17) << "|" << std::left << std::setw(33) << "|" << std::left << std::setw(14) << "|" << endl; cout << "aktueller Kontostand: " << getAccountAmount().toString() << "\n"; cout << setfill(' ') << flush; }
void Deposit::execute(){ BankDatabase bankDatabse = getBankDataBalance(); Screen screen = getScreen(); this->money = getDepositAmountFromKBD(); bankDatabse.credit(getAccountNumber(), bankDatabse.setBalance(money));// setbalance를 통해 간단히 표현(다형성의 장점) }