| using System;
public class BankAccount {
private double interestRate;
private string owner;
private decimal balance;
private long accountNumber;
private static long nextAccountNumber = 0;
public BankAccount(string owner) {
nextAccountNumber++;
this.accountNumber = nextAccountNumber;
this.interestRate = 0.0;
this.owner = owner;
this.balance = 0.0M;
}
public BankAccount(string owner, double interestRate) {
nextAccountNumber++;
this.accountNumber = nextAccountNumber;
this.interestRate = interestRate;
this.owner = owner;
this.balance = 0.0M;
}
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 owner + "'s account, no. " + accountNumber + " holds " +
+ balance + " kroner";
}
} |