static void Main(string[] args) { CreditCard creditCard = new PlatinumFactory().CreateProduct(); if (creditCard != null) { Console.WriteLine("Card Type : " + creditCard.GetCardType()); Console.WriteLine("Credit Limit : " + creditCard.GetCreditLimit()); Console.WriteLine("Annual Charge :" + creditCard.GetAnnualCharge()); } else { Console.Write("Invalid Card Type"); } Console.WriteLine("--------------"); creditCard = new MoneyBackFactory().CreateProduct(); if (creditCard != null) { Console.WriteLine("Card Type : " + creditCard.GetCardType()); Console.WriteLine("Credit Limit : " + creditCard.GetCreditLimit()); Console.WriteLine("Annual Charge :" + creditCard.GetAnnualCharge()); } else { Console.Write("Invalid Card Type"); } Console.ReadLine(); }
public static void Main(string[] args) { CardFactory factory = null; Console.Write("Enter the card type you would like to visit: "); string card = Console.ReadLine(); switch (card.ToLower()) { case "moneyback": factory = new MoneyBackFactory(50000, 0); break; case "titanium": factory = new TitaniumFactory(100000, 500); break; case "platinum": factory = new PlatinumFactory(500000, 1000); break; default: break; } CreditCard creditCard = factory.GetCreditCard(); Console.WriteLine("\nYour card details are below : \n"); Console.WriteLine("Card Type: {0}\nCredit Limit: {1}\nAnnual Charge: {2}", creditCard.CardType, creditCard.CreditLimit, creditCard.AnnualCharge); }