Skip to content

Instantly share code, notes, and snippets.

@charlesreid1
Created April 18, 2017 18:36
Show Gist options
  • Save charlesreid1/78f4e3c5a970839b174454240b72afef to your computer and use it in GitHub Desktop.
Save charlesreid1/78f4e3c5a970839b174454240b72afef to your computer and use it in GitHub Desktop.
public class MinMaxAccount extends BankAccount {
private double minBalance;
private double maxBalance;
public MinMaxAccount(Startup s) {
super(s);
this.minBalance = getBalance();
this.maxBalance = getBalance();
}
public void debit(Debit d) {
super.debit(d);
double balance = getBalance();
if(balance < this.minBalance) {
this.minBalance = balance;
}
}
public void credit(Credit c) {
super.credit(c);
if(getBalance() > this.maxBalance) {
this.maxBalance = getBalance();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment