public void Run()
        {
            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();
        }
Exemplo n.º 2
0
        public void TestMain()
        {
            CardFactory factory = null;

            string car = "moneyback";

            switch (car.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("Card Type: {0}\nCredit Limit: {1}\nAnnual Charge: {2}",
                              creditCard.CardType, creditCard.CreditLimit, creditCard.AnnualCharge);
        }