08-Abstract Factory Pattern - Week6
08-Abstract Factory Pattern - Week6
Pattern
Abstract Factory Pattern
• Abstract Factory design pattern is one of the
Creational pattern. Abstract Factory pattern is almost similar
to Factory Pattern is considered as another layer
of abstraction over factory pattern.
• Abstract Factory patterns work around a super-factory which
creates other factories.
Advantage and Usage
AbstractFactory bankFactory = FactoryCreator.getFactory("Bank");
Bank b=bankFactory.getBank(bankName);
Step 8
System.out.print("\n");
System.out.print("Enter the interest rate for "+b.getBankName()+ ": ");
double rate=Double.parseDouble(br.readLine());
System.out.print("\n");
System.out.print("Enter the loan amount you want to take: ");
double loanAmount=Double.parseDouble(br.readLine());
System.out.print("\n");
System.out.print("Enter the number of years to pay your entire loan amou
nt: ");
int years=Integer.parseInt(br.readLine());
Step 8
System.out.print("\n");
System.out.println("you are taking the loan from "+ b.getBankNa
me());
AbstractFactory loanFactory = FactoryCreator.getFactory("Loan")
;
Loan l=loanFactory.getLoan(loanName);
l.getInterestRate(rate);
l.calculateLoanPayment(loanAmount,years);
}
}//End of the AbstractFactoryPatternExample