associative-arrays/bank-account.cs - The class BankAccount - without owner. | Lecture 5 - slide 15 : 29 Program 2 |
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"; } }