Project 10 CECS277 solution




5/5 - (7 votes)

Assume we have three different credit cards: Visa, Discover, and AmericanExpress
options and all of them implement abstract class CreditCard. You need to instantiate one
of these classes, but you don’t know which of them, it depends on the user. This is a
perfect scenario for the Factory Method design pattern. Please see the UML diagram and
sample output below for details of how to implement this design.
Sample output:
In CreditCardDemo: You should be creating an instance of CardFactory and based on user input
you will instantiate the right credit card. Values for credit limit and annual Charges is hard coded.
Program is looping until user enters quit.