A simple bank account created as an everyday example for the OOP course. Used in particular for demonstrating inheritance. More...
Inherited by CheckAccount, LotteryAccount, and SavingsAccount.
Public Member Functions | |
BankAccount (string o, decimal b, double ir) | |
Construct a bank account from owner, balance, and interestRate. | |
BankAccount (string o, double ir) | |
Construct a bank account from owner and interestRate. | |
virtual void | Withdraw (decimal amount) |
| |
virtual void | Deposit (decimal amount) |
Withdraw an amount of money from the account. This increases the balance of the account. | |
virtual void | AddInterests () |
Add the annual interest to the account. This may increase the current balance of the account. | |
override string | ToString () |
Return a text string that represents this account for output purposes. | |
Protected Attributes | |
double | interestRate |
string | owner |
decimal | balance |
Properties | |
virtual decimal | Balance [get] |
Returns the current amount of the bank account with affecting the account. |
A simple bank account created as an everyday example for the OOP course. Used in particular for demonstrating inheritance.
BankAccount ba = new BankAccount("Peter"); ba.Deposit(100.0); ba.Withdraw(50.0);
Definition at line 20 of file bank-account.cs.
BankAccount.BankAccount | ( | string | o, | |
decimal | b, | |||
double | ir | |||
) |
Construct a bank account from owner, balance, and interestRate.
o | The owners name | |
b | The initial amount of this account | |
ir | The interest rate. Annual interet is calculated as balance * interestRate |
Definition at line 35 of file bank-account.cs.
References balance, interestRate, and owner.
BankAccount.BankAccount | ( | string | o, | |
double | ir | |||
) |
Construct a bank account from owner and interestRate.
o | The owners name | |
ir | The interest rate. Annual interet is calculated as balance * interestRate |
Definition at line 49 of file bank-account.cs.
virtual void BankAccount.AddInterests | ( | ) | [virtual] |
Add the annual interest to the account. This may increase the current balance of the account.
Reimplemented in LotteryAccount, and SavingsAccount.
Definition at line 92 of file bank-account.cs.
References balance, and interestRate.
virtual void BankAccount.Deposit | ( | decimal | amount | ) | [virtual] |
Withdraw an amount of money from the account. This increases the balance of the account.
amount | The amount of money to deposit to the account. Precondition: Must be non-negative. |
Definition at line 84 of file bank-account.cs.
References balance.
override string BankAccount.ToString | ( | ) |
Return a text string that represents this account for output purposes.
Reimplemented in CheckAccount, LotteryAccount, and SavingsAccount.
Definition at line 100 of file bank-account.cs.
virtual void BankAccount.Withdraw | ( | decimal | amount | ) | [virtual] |
amount | The amount of money to withdraw from the account. Precondition: Must be non-negative. |
Reimplemented in CheckAccount, and SavingsAccount.
Definition at line 72 of file bank-account.cs.
References balance.
decimal BankAccount.balance [protected] |
Definition at line 24 of file bank-account.cs.
Referenced by SavingsAccount.AddInterests(), LotteryAccount.AddInterests(), AddInterests(), BankAccount(), Deposit(), SavingsAccount.ToString(), LotteryAccount.ToString(), CheckAccount.ToString(), ToString(), SavingsAccount.Withdraw(), CheckAccount.Withdraw(), and Withdraw().
double BankAccount.interestRate [protected] |
Definition at line 22 of file bank-account.cs.
Referenced by SavingsAccount.AddInterests(), AddInterests(), BankAccount(), and CheckAccount.Withdraw().
string BankAccount.owner [protected] |
Definition at line 23 of file bank-account.cs.
Referenced by BankAccount(), SavingsAccount.ToString(), LotteryAccount.ToString(), CheckAccount.ToString(), and ToString().
virtual decimal BankAccount.Balance [get] |
Returns the current amount of the bank account with affecting the account.
The amount of money
Definition at line 58 of file bank-account.cs.