Hi All,
Java 8 Custom Functional Interface | Real-Time Enterprise Loan Approval Rule Engine | Interview Ex
Today I have released new video on "Java 8 Custom Functional Interface | Real-Time Enterprise Loan Approval Rule Engine | Interview Ex"
This is frequently asked question in Java Interview.
Please watch full video, share, like and Subscribe Youtube channel and press bell icon. So you will get latest video notification.
|
public class LoanApprovalDemo { public static void main(String[] args) { Customer customer1 = new Customer("Shruti", 28,85000, 760, true); Customer customer2 = new Customer("Aman", 20, 100000, 560, false); String result;
result = LoanApprovalService.approvalRule.evaluate(customer1); System.out.println("Shruti's Loan Approval Status : "+ result);
result = LoanApprovalService.approvalRule.evaluate(customer2); System.out.println("Aman's Loan Approval Status : "+ result); } } package org.practice.basicprgms; public class LoanApprovalService { public static LoanApprovalRule approvalRule = customer -> {
if(customer.getAge() < 21) return "Rejected: Age Should be greater than 21";
if(customer.getSalary() < 50000) return "Rejected: Salary should be greater than 50000";
if(customer.getCreditScore() < 700) return "Rejected: Credit score must be above 700";
if(customer.isExistingCustomer()) return "Approved with Waive off Processing fees";
return "Loan Approved"; }; } package org.practice.basicprgms; public class Customer { private String name; private int age; private double salary; private int creditScore; private boolean existingCustomer;
public Customer() { super(); } public Customer(String name, int age, double salary, int creditScore, boolean existingCustomer) { super(); this.name = name; this.age = age; this.salary = salary; this.creditScore = creditScore; this.existingCustomer = existingCustomer; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; } public int getCreditScore() { return creditScore; } public void setCreditScore(int creditScore) { this.creditScore = creditScore; } public boolean isExistingCustomer() { return existingCustomer; } public void setExistingCustomer(boolean existingCustomer) { this.existingCustomer = existingCustomer; } } |
0 Comments