Created
April 9, 2014 12:06
-
-
Save gabrielruiu/10261502 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
public class RunApp { | |
private List<String> expiredCCList; | |
private List<String> stolenCCList; | |
public Main { | |
populateExpiredList(); | |
populateStolenList(); | |
} | |
public boolean checkCreditCard(String strCardNumber, double amount, String luhnStatus) ExpiredCreditCardException, InvalidCreditCardException, { | |
if(luhnStatus.equals("PASSED")) { | |
if(expiredCCList.contains(strCardNumber)) { | |
throw new ExpiredCreditCardException(); | |
} else if(stolenCCList.contains(strCardNumber) { | |
throw new StolenCreditCardException(); | |
} | |
} else if(luhnStatus.equals("FAILED")) { // invalid | |
throw new InvalidCreditCardException(); | |
} else { | |
payItem(amount); | |
System.out.print("Thank you for shopping with us!"); | |
} | |
return true; | |
} | |
private void populateExpiredList() { | |
expiredCCList = new ArrayList<String>(); | |
while (reading_CC_Expired.xml) { | |
String expiredCC = readEntryFromExpiredXML(); | |
expiredCCList.add(expiredCC); | |
} | |
} | |
private void populateStolenList() { | |
stolenCCList = new ArrayList<String>(); | |
while (reading_CC_Stolen.xml) { | |
String stolenCC = readEntryFromStolenXML(); | |
stolenCCList.add(stolenCC); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment