Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Credit {
- public enum CreditType {
- STUDENT,
- HOUSE,
- AUTO
- }
- private CreditType creditType;
- private double interest;
- public Credit(CreditType creditType) {
- this.creditType = creditType;
- setInterest(creditType);
- }
- public CreditType getCreditType() {
- return creditType;
- }
- public void setCreditType(CreditType creditType) {
- this.creditType = creditType;
- setInterest(creditType);
- }
- public double getInterest() {
- return interest;
- }
- private void setInterest(CreditType creditType) {
- switch (creditType) {
- case STUDENT:
- this.interest = 10.0;
- break;
- case HOUSE:
- this.interest = 7.0;
- break;
- case AUTO:
- this.interest = 5.0;
- break;
- }
- }
- @Override
- public String toString() {
- return "Credit type: " + getCreditType() + " Interest " + getInterest() + "%";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement