Skip to content

Instantly share code, notes, and snippets.

@Vaysman
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vaysman/bb1640bd65062f71db56 to your computer and use it in GitHub Desktop.
Save Vaysman/bb1640bd65062f71db56 to your computer and use it in GitHub Desktop.
package com.luxoft.bankapp.model;
import com.luxoft.bankapp.model.exception.OverDraftLimitExceededException;
// this is an incomplete class. use it as example.
public class CheckingAccount extends AbstractAccount {
private float overdraft;
public CheckingAccount(float balance) {
super(balance);
}
public CheckingAccount(float balance, float overdraft) {
this(balance);
if(overdraft < 0) {
throw new IllegalArgumentException("Overdraft must be greater than or equal to 0");
}
this.overdraft = overdraft;
}
public float getOverdraft() {
return overdraft;
}
public void withdraw(float amount) {
if(balance + overdraft < amount) {
throw new OverDraftLimitExceededException();
}
balance -= amount;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment