using System;
public class BankAccount {
private double interestRate;
private decimal balance;
public BankAccount(double interestRate, decimal balance) {
this.interestRate = interestRate;
this.balance = balance;
}
public decimal Balance () {
return balance;
}
public void Withdraw (decimal amount) {
balance -= amount;
}
public void Deposit (decimal amount) {
balance += amount;
}
public void AddInterests() {
balance = balance + balance * (decimal)interestRate;
}
public override string ToString() {
return "The account holds " + balance + " kroner";
}
} | |
The owner of the bank account
is now dealt with external to
the BankAccount class.
|