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) {
- if(creditType == CreditType.STUDENT) {
- this.interest = 10.0;
- } else if (creditType == CreditType.HOUSE) {
- this.interest = 7.0;
- } else if (creditType == CreditType.AUTO) {
- this.interest = 5.0;
- }
- }
- @Override
- public String toString() {
- return "Credit type: " + getCreditType() + " Interest " + getInterest() + "%";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement