Пример #1
0
        static void Main(string[] args)
        {
            // The code provided will print ‘Hello World’ to the console.
            // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
            ICreaditCard creditPlatinum = new PlatinumFactory().CreateProduct();

            Console.WriteLine(creditPlatinum.GetCreditLimit());
            Console.WriteLine(creditPlatinum.GetCardType());


            ICreaditCard creditTitanium = new TitaniumFactory().CreateProduct();

            Console.WriteLine(creditTitanium.GetCreditLimit());
            Console.WriteLine(creditTitanium.GetCardType());


            ICreaditCard creditGold = new GoldFactory().CreateProduct();

            Console.WriteLine(creditGold.GetCreditLimit());
            Console.WriteLine(creditGold.GetCardType());


            Console.ReadKey();

            // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app!
        }
Пример #2
0
        static void Main(string[] args)
        {
            CardFactory factory = null;

            Console.Write("Enter the card type you would like to visit: ");
            string car = Console.ReadLine();

            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("\nYour card details are below : \n");
            Console.WriteLine("Card Type: {0}\nCredit Limit: {1}\nAnnual Charge: {2}",
                              creditCard.CardType, creditCard.CreditLimit, creditCard.AnnualCharge);
            Console.ReadKey();
        }