Challenge: Abstract Pattern
In this challenge, you have to implement the abstract pattern to solve the given problem.
Problem statement
In this challenge, you have the abstract constructor function Loans
. There are three types of loans that can be given:
-
HomeLoan
-
StudentLoan
-
PersonalLoan
You need to implement Loans
such that it decides which loan instance to instantiate, given the input parameters. Implement a function getloan
for this purpose. getloan
should take the following parameters:
-
type
: type of loan -
amount
: amount of the loan -
duration
: duration of the loan
All the three loans mentioned above have the following properties:
-
amount
: the amount of loan required (in dollars) -
duration
: the duration of time (in years) for which the loan is borrowed -
interest
...