BankAccount.cpp
上传用户:sz0451
上传日期:2022-07-29
资源大小:256k
文件大小:1k
- #include "stdafx.h"
- #include "BankAccount.h"
- BankAccount::BankAccount(String * holder)
- :accountHolder(holder), balance(0.0)
- {
- }
- BankAccount::~BankAccount()
- {
- }
- void BankAccount::Credit(double amount)
- {
- balance += amount;
- Console::Write(S"After credit, new balance is: ");
- Console::WriteLine(balance);
- }
- void BankAccount::Debit(double amount)
- {
- if (CanDebit(amount))
- {
- balance -= amount;
- Console::Write(S"Debit succeeded, new balance is: ");
- Console::WriteLine(balance);
- }
- else
- {
- Console::Write(S"Debit refused, balance is still: ");
- Console::WriteLine(balance);
- }
- }
- String * BankAccount::ToString()
- {
- String * result = new String(S"Account holder: ");
- result = String::Concat(result, accountHolder);
- result = String::Concat(result, S", Balance: ");
- result = String::Concat(result, balance.ToString());
- return result;
- }