| using System;
public class BankAccount {
private string owner;
private decimal balance;
private BankAccount leftAccount, rightAccount;
public BankAccount(string owner, decimal balance) {
this.owner = owner;
this.balance = balance;
this.leftAccount = null;
this.rightAccount = null;
}
public BankAccount(string owner, decimal balance, BankAccount leftAccount, BankAccount rightAccount) {
this.owner = owner;
this.balance = balance;
this.leftAccount = leftAccount;
this.rightAccount = rightAccount;
}
private bool LeafAccount(){
return leftAccount == null && rightAccount == null;
}
public decimal Balance () {
// Exercise
}
public void Withdraw (decimal amount) {
// Exercise
}
public void Deposit (decimal amount) {
// Exercise
}
public void DistributeEven(){
// Exercise
}
public override string ToString() {
return String.Format("{0} {1,12:c2} (local amount: {2,12:c2})", owner, Balance(), balance);
}
} |