using System;
public class BankAccount {
private string owner;
private decimal balance;
public BankAccount(string owner, decimal balance) {
this.owner = owner;
this.balance = balance;
}
public decimal Balance {
get {return balance;}
}
public void Deposit(decimal amount){
balance += amount;
}
public void Withdraw(decimal amount){
balance -= amount;
}
public override string ToString() {
return owner + "'s account holds " +
+ balance + " kroner";
}
} | |
The instance variable balance.
Coding style: starts with lower case letter.
A trivial property (getter).
Coding style: starts with upper case letter.
|