Answer:
}
/**
* lessThan() returns true if this account's number is less than the
* argument's account number.
**/
public boolean lessThan(Keyable x) {
return number < ((AccountData) x).number;
}
/**
* getOwner() returns the name of this account's owner.
**/
public String getOwner() {
return name;
}
/**
* toString() returns a String version of this account's number.
**/
public String toString() {
return "" + number;
}
/**
* getBalance() returns the balance of this account.
**/
public int getBalance() {
return balance;
}
/**
* withdraw() reduces the balance by the withdrawal amount "amt".
**/
public void withdraw(int amt) {
if (amt <= balance) {
balance = balance - amt;
} else {
System.out.println("Error: Insufficient funds: " + amt);
}
}
/**
* deposit() deposits "amt" dollars into this account.
**/
public void deposit(int amt) {
if (amt >= 0) {
balance = balance + amt;
} else {
System.out.println("Error: Tried to deposit less than 0: " + amt);
}
}
/**
* getNumber() returns this account's number.
**/
public int getNumber() {
return number;
}
/**
* getKey() returns this account's account number as the key to use for
* sorting and comparison.
**/
public int getKey() {
return number;
}
}
Step-by-step explanation: