Oops
Oops
Loan Approval System simulates a bank’s loan approval process for different customer
profiles (e.g., salaried employees, business owners, etc.).
Built using fundamental C++ OOP principles – demonstrating encapsulation (organizing
data/functions within classes), inheritance (using base & derived classes for shared
interfaces), and polymorphism (flexible behavior via base-class pointers).
Employs Strategy and Factory design patterns to handle varied approval logic. The Strategy
pattern lets the program choose different approval algorithms at runtime (one for each
customer type). The Factory pattern is used to create the appropriate strategy object, making
it easy to add new customer types without changing core logic.
Slide 3: UML Class Diagram
Role-Based Workflow: After a successful login, the system routes the user to the
appropriate workflow:
o Admin: Gains access to administrative functions (e.g. view all loan
application data, manage loans).
o User: Proceeds to the standard user flow (e.g. apply for a new loan).
This design ensures that an Admin has a different experience (and privileges) than a
normal user once authenticated. The code below illustrates the updated login logic
with role handling:
Slide 5: Customer Class
Customer Profile: The Customer class encapsulates loan applicant data and ties a
customer to an approval strategy. When a Customer is created, it selects an approval
strategy based on the customer’s profile type (using the factory). It also holds a Loan
instance for the requested loan details.
Slide 6: Loan Class
Loan Details: The Loan class encapsulates information about a loan request. It stores
the loan amount and duration, and provides a method to check if the loan is overdue
(based on a simple simulation of time passing).
Comments: In this simple model, when monthsRemaining drops to 0 or below, the loan is
considered due/overdue. The payMonth() function simulates time advancing or payments
being made. (In a real system, dates and payment schedules would be used instead of a
counter.)
Slide 7: Credit Score Converter Function
Utility Function: A standalone function is used to convert or interpret credit score
values. This can help translate a raw credit score into a category that the approval
logic might use (e.g., “Good” or “Poor” credit).
This function takes an integer credit score and returns a string category. For example, a score
of 700 would yield "Good". Such a converter could be used to adjust loan terms or approval
thresholds based on categories, but in our project the numeric score is used directly in the
strategy logic for simplicity.
Comments: In this example, a salaried customer with a credit score of 650 or above
can be approved for loans up to 50,000. The check uses data from the Customer and Loan
objects. By changing the thresholds or adding more conditions, we can easily tweak the
approval policy for salaried customers. BusinessApproval and SelfEmployedApproval
classes (not shown here) would override approveLoan with different rules suitable for those
profiles.
Slide 10: Approval Strategy Factory
Factory Pattern: The ApprovalFactory class provides a static method to create the
appropriate ApprovalStrategy object based on the customer’s profile type. This
separates the decision of which strategy to use from the rest of the code. The
Customer simply asks the factory for a strategy, without worrying about the concrete
class names.
Here, getStrategy checks the profile type and allocates the corresponding strategy
object. For example, if profileType is "Business", it returns a new BusinessApproval(). Using
a factory method centralizes object creation logicfile-jx2pu6frxwv6fncn4hdfj5, making it
easy to add new types (just extend ApprovalStrategy and update this method) without
scattering new calls throughout the code. (Note: In a full program, we would ensure to delete
the allocated strategy or use smart pointers to avoid memory leaks.)