/**
A bank account has a balance that can be changed by
deposits and withdrawals.
*/
public class BankAccount : IComparable
{
//Overrides the toString method in Object class
public string ToString()
return GetType().FullName + "[balance= " + balance + "]";
}
//Implements the compareTo method in the Comparable interface
public int CompareTo (object anObject)
BankAccount anAccount = (BankAccount) anObject;
if (Math.abs(balance - anAccount.getBalance()) <= EPSILON) return 0;
if (balance < anAccount.getBalance()) return -1;
return 1;
Constructs a bank account with a zero balance.
public BankAccount()
balance = 0;
Constructs a bank account with a given balance.
public BankAccount(double initialBalance)
balance = initialBalance;
Error(s):
(60:10) Invalid token 'double' in class, struct, or interface member declaration