Last active
August 29, 2015 14:12
-
-
Save Vaysman/bb1640bd65062f71db56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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