A simple bank account created as an everyday example for the OOP course. Used in particular for demonstrating inheritance. More...
Public Member Functions | |
BankAccount (string owner) | |
Construct a bank account from owner. The interestRate is given the default value 0.0. The balance is given the default value 0.0. | |
BankAccount (string owner, double balance) | |
Construct a bank account from owner, balance, and interestRate. The interestRate is given the default value 0.0. | |
BankAccount (string owner, double balance, double interestRate) | |
Construct a bank account from owner, balance, and interestRate. | |
void | Withdraw (double amount) |
Withdraw an amount of money from the account. This decreases the balance of the account. | |
void | Deposit (double amount) |
Withdraw an amount of money from the account. This increases the balance of the account. | |
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. | |
Properties | |
double | Balance [get] |
Returns the current amount of the bank account without affecting the account. | |
double | InterestRate [get] |
Return the interest rate of the account. |
A simple bank account created as an everyday example for the OOP course. Used in particular for demonstrating inheritance.
Definition at line 7 of file bank-account.cs.
BankAccount.BankAccount | ( | string | owner | ) |
Construct a bank account from owner. The interestRate is given the default value 0.0. The balance is given the default value 0.0.
owner | The owners name. A string. |
Definition at line 19 of file bank-account.cs.
BankAccount.BankAccount | ( | string | owner, | |
double | balance | |||
) |
Construct a bank account from owner, balance, and interestRate. The interestRate is given the default value 0.0.
owner | The owners name | |
balance | The initial amount of this account |
Definition at line 29 of file bank-account.cs.
BankAccount.BankAccount | ( | string | owner, | |
double | balance, | |||
double | interestRate | |||
) |
Construct a bank account from owner, balance, and interestRate.
owner | The owners name | |
balance | The initial amount of this account | |
interestRate | The interest rate. Annual interet is calculated as balance * interestRate |
Definition at line 42 of file bank-account.cs.
void BankAccount.AddInterests | ( | ) |
Add the annual interest to the account. This may increase the current balance of the account.
Definition at line 97 of file bank-account.cs.
void BankAccount.Deposit | ( | double | amount | ) |
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 89 of file bank-account.cs.
override string BankAccount.ToString | ( | ) |
Return a text string that represents this account for output purposes.
Definition at line 105 of file bank-account.cs.
void BankAccount.Withdraw | ( | double | amount | ) |
Withdraw an amount of money from the account. This decreases the balance of the account.
amount | The amount of money to withdraw from the account. Precondition: Must be non-negative. |
Definition at line 77 of file bank-account.cs.
double BankAccount.Balance [get] |
Returns the current amount of the bank account without affecting the account.
Accesses the amount of money in the account
Definition at line 53 of file bank-account.cs.
double BankAccount.InterestRate [get] |
Return the interest rate of the account.
Accesses the interest rate of the account
Definition at line 63 of file bank-account.cs.