Last active
December 16, 2015 02:09
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 org.sxvarg2.enums; | |
public abstract class LoanType implements Enumerable { | |
public static final LoanType HOME = new LoanType(7, 20) { | |
public boolean isEligible(int age, int creditScore) { | |
return age < 30 && creditScore > 700; | |
} | |
}; | |
public static final LoanType CAR = new LoanType(5, 5) { | |
public boolean isEligible(int age, int creditScore) { | |
return age < 50 && creditScore > 700; | |
} | |
}; | |
public static final LoanType EDUCATION = new LoanType(2, 20) { | |
public boolean isEligible(int age, int creditScore) { | |
return age < 25 && creditScore > 630; | |
} | |
}; | |
public static final LoanType STARTUP = new LoanType(9, 5) { | |
public boolean isEligible(int age, int creditScore) { | |
return age < 40 && creditScore > 770; | |
} | |
}; | |
private static final Object[] registeredTypes = new Object[] {HOME, CAR, EDUCATION, STARTUP }; | |
private final int interestPercentage; | |
private final int maxRepayPeriod; | |
public int getInterestPercentage() { | |
return interestPercentage; | |
} | |
public int getMaxRepayPeriod() { | |
return maxRepayPeriod; | |
} | |
private LoanType(final int interestPercentage, final intmaxRepayPeriod) { | |
this.interestPercentage = interestPercentage; | |
this.maxRepayPeriod = maxRepayPeriod; | |
} | |
public final Object[] values() { | |
return registeredTypes; | |
} | |
public abstract boolean isEligible(int age, int creditScore); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment