Example #1
0
        public void Information() //Promting the user with a menu to insert name and age
        {
            Console.WriteLine("Bank Register");
            Console.Write("Name:");
            string name = Console.ReadLine();

            Console.Write("Age:");
            int          age          = int.Parse(Console.ReadLine());
            DebitCard    debit        = new DebitCard(name);
            Maestro      maestro      = new Maestro(name);
            Mastercard   mastercard   = new Mastercard(name);
            Visaelectron visaelectron = new Visaelectron(name);
            Visa         visa         = new Visa(name);

            if (age <= 18)//Only showing cards that are relevant for the users age
            {
                Cardform(debit);
            }
            if (age >= 18)
            {
                Cardform(visa);
                Cardform(maestro);
            }
            if (age >= 15)
            {
                Cardform(visaelectron);
            }
            Cardform(mastercard);
        }
Example #2
0
        static void Main(string[] args)
        {
            //Instantiere kortene
            VISAElectron ve  = new VISAElectron("Christian Bøgh");
            VISA         v   = new VISA("Christian Bøgh");
            Mastercard   mas = new Mastercard("Christian Bøgh");
            Maestro      mae = new Maestro("Christian Bøgh");
            DebitCard    d   = new DebitCard("Christian Bøgh");

            //Udskriver ToString metoden
            Console.WriteLine(ve.ToString());
            Console.WriteLine(v.ToString());
            Console.WriteLine(mas.ToString());
            Console.WriteLine(mae.ToString());
            Console.WriteLine(d.ToString());

            //Pauser koden og venter på klikket på en tast
            Console.ReadKey();
        }
Example #3
0
File: Program.cs Project: KavTV/H2
        static void Main(string[] args)
        {
            Mastercard m = new Mastercard("kasper");

            m.Pay(4000);
            m.Pay(2000);
            if (m.Withdraw(4000) && m.Validate(4000))
            {
                Console.WriteLine("Du har hævet pengene");
            }
            if (m.Withdraw(1001) && m.Validate(1001))
            {
                Console.WriteLine("du har hævet flere penge");
            }
            else
            {
                Console.WriteLine("Du har hævet maks for idag eller måneden");
            }

            Debitcard d = new Debitcard("kasp");
            bool      j = d.Validate(5000);
        }
Example #4
0
        static void Main(string[] args)
        {
            //Start of menu
            Console.WriteLine("Welcome to this fancy bank");
            Console.Write("Press Enter:");
            Console.ReadLine();

            //Ask for a name for the card
            Console.WriteLine("What is your name:");
            string name = Console.ReadLine();

            //instances
            Card    withdrawalCard = new WithdrawalCard(name);
            Account account        = new Account(name);

            //START of GUI


            //user input to navigate the menu
            int    userInput;
            string age;
            int    userAge;

            do
            {
                //Menu after your name is inputted
                Console.Clear();
                Console.WriteLine("Press (1) to make a Mastercard\n" +
                                  "Press (2) to make a VISA Dancard\n" +
                                  "Press (3) to make a Maestro card\n" +
                                  "Press (4) to make a VISA Electron card\n" +
                                  "Press (5) to exit");

                string input = Console.ReadLine();
                userInput = int.Parse(input);
                switch (userInput)
                {
                //If Mastercard is chosen
                case 1:
                    Card mastercard = new Mastercard(name);
                    Console.Clear();
                    Console.WriteLine("Welcome " + name + "\nHere is your new card:\n");
                    Console.WriteLine("------------------------");
                    Console.WriteLine(mastercard.GetType().Name);
                    Console.WriteLine("Belongs to: " + name);
                    Console.WriteLine("Card number: " + mastercard.CardNumber);
                    Console.WriteLine("Expiration date: " + mastercard.ExpireDate);
                    Console.WriteLine("Account number: " + account.AccountNumber);
                    Console.WriteLine("------------------------\n");
                    Console.Write("Press enter to continue: ");
                    Console.ReadLine();
                    Console.Clear();
                    break;

                //If VISA Dancard is chosen
                case 2:
                    Card visaDankort = new VISADankort(name);
                    Console.Clear();
                    Console.WriteLine("How old are you?");
                    age     = Console.ReadLine();
                    userAge = int.Parse(age);
                    if (visaDankort.MinAge <= userAge)
                    {
                        Console.Clear();
                        Console.WriteLine("Welcome " + name + "\nHere is your new card:\n");
                        Console.WriteLine("------------------------");
                        Console.WriteLine(visaDankort.GetType().Name);
                        Console.WriteLine("Belongs to: " + name);
                        Console.WriteLine("Card number: " + visaDankort.CardNumber);
                        Console.WriteLine("Expiration date: " + visaDankort.ExpireDate);
                        Console.WriteLine("Account number: " + account.AccountNumber);
                        Console.WriteLine("------------------------\n");
                        Console.Write("Press enter to continue: ");
                        Console.ReadLine();
                        Console.Clear();
                    }
                    else
                    {
                        Console.WriteLine($"Sorry, we cannot make a {visaDankort.GetType().Name} card because you are too young.\n" +
                                          $"Would you like to get a {withdrawalCard.GetType().Name} instead? ( yes / no )");
                        string withdrawCard = Console.ReadLine();
                        if (withdrawCard == "yes")
                        {
                            Console.Clear();
                            Console.WriteLine("Here is your new card:" + name + "\n");
                            Console.WriteLine("------------------------");
                            Console.WriteLine(withdrawalCard.GetType().Name);
                            Console.WriteLine("Belongs to: " + name);
                            Console.WriteLine("Card number: " + withdrawalCard.CardNumber);
                            Console.WriteLine("Expiration date: " + withdrawalCard.ExpireDate);
                            Console.WriteLine("Account number: " + account.AccountNumber);
                            Console.WriteLine("------------------------\n");
                            Console.Write("Press enter to continue: ");
                            Console.ReadLine();
                        }
                        else if (withdrawCard == "no")
                        {
                            Console.Clear();
                            Console.WriteLine("Have a nice day\n");
                            Console.Write("Press enter to continue: ");
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.Clear();
                            Console.WriteLine("There seemed to have been a wrong input\n");
                            Console.Write("Press enter to continue: ");
                            Console.ReadLine();
                        }
                    }
                    break;

                //If Maestro card is chosen
                case 3:
                    Card maestro = new Maestro(name);
                    Console.Clear();
                    Console.WriteLine("How old are you?");
                    age     = Console.ReadLine();
                    userAge = int.Parse(age);
                    if (maestro.MinAge <= userAge)
                    {
                        Console.Clear();
                        Console.WriteLine("Welcome " + name + "\nHere is your new card:\n");
                        Console.WriteLine("------------------------");
                        Console.WriteLine(maestro.GetType().Name);
                        Console.WriteLine("Belongs to: " + name);
                        Console.WriteLine("Card number: " + maestro.CardNumber);
                        Console.WriteLine("Expiration date: " + maestro.ExpireDate);
                        Console.WriteLine("Account number: " + account.AccountNumber);
                        Console.WriteLine("------------------------\n");
                        Console.Write("Press enter to continue: ");
                        Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine($"Sorry, we cannot make a {maestro.GetType().Name} card because you are too young.\n" +
                                          $"Would you like to get a {withdrawalCard.GetType().Name} instead? ( yes / no )");
                        string withdrawCard = Console.ReadLine();
                        if (withdrawCard == "yes")
                        {
                            Console.Clear();
                            Console.WriteLine("Here is your new card:" + name + "\n");
                            Console.WriteLine("------------------------");
                            Console.WriteLine(withdrawalCard.GetType().Name);
                            Console.WriteLine("Belongs to: " + name);
                            Console.WriteLine("Card number: " + withdrawalCard.CardNumber);
                            Console.WriteLine("Expiration date: " + withdrawalCard.ExpireDate);
                            Console.WriteLine("Account number: " + account.AccountNumber);
                            Console.WriteLine("------------------------\n");
                            Console.Write("Press enter to continue: ");
                            Console.ReadLine();
                        }
                        else if (withdrawCard == "no")
                        {
                            Console.Clear();
                            Console.WriteLine("Have a nice day\n");
                            Console.Write("Press enter to continue: ");
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.Clear();
                            Console.WriteLine("There seemed to have been a wrong input\n");
                            Console.Write("Press enter to continue: ");
                            Console.ReadLine();
                        }
                    }
                    break;

                //If VISA Electron is chosen
                case 4:
                    Card visaElectron = new VISAElectron(name);
                    Console.Clear();
                    Console.WriteLine("How old are you?");
                    age     = Console.ReadLine();
                    userAge = int.Parse(age);
                    if (visaElectron.MinAge <= userAge)
                    {
                        Console.Clear();
                        Console.WriteLine("Welcome " + name + "\nHere is your new card:\n");
                        Console.WriteLine("------------------------");
                        Console.WriteLine(visaElectron.GetType().Name);
                        Console.WriteLine("Belongs to: " + name);
                        Console.WriteLine("Card number: " + visaElectron.CardNumber);
                        Console.WriteLine("Expiration date: " + visaElectron.ExpireDate);
                        Console.WriteLine("Account number: " + account.AccountNumber);
                        Console.WriteLine("------------------------\n");
                        Console.Write("Press enter to continue: ");
                        Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine($"Sorry, we cannot make a {visaElectron.GetType().Name} card because you are too young.\n" +
                                          $"Would you like to get a {withdrawalCard.GetType().Name} instead? ( yes / no )");
                        string withdrawCard = Console.ReadLine();
                        if (withdrawCard == "yes")
                        {
                            Console.Clear();
                            Console.WriteLine("Here is your new card:" + name + "\n");
                            Console.WriteLine("------------------------");
                            Console.WriteLine(withdrawalCard.GetType().Name);
                            Console.WriteLine("Belongs to: " + name);
                            Console.WriteLine("Card number: " + withdrawalCard.CardNumber);
                            Console.WriteLine("Expiration date: " + withdrawalCard.ExpireDate);
                            Console.WriteLine("Account number: " + account.AccountNumber);
                            Console.WriteLine("------------------------\n");
                            Console.Write("Press enter to continue: ");
                            Console.ReadLine();
                        }
                        else if (withdrawCard == "no")
                        {
                            Console.Clear();
                            Console.WriteLine("Have a nice day\n");
                            Console.Write("Press enter to continue: ");
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.Clear();
                            Console.WriteLine("There seemed to have been a wrong input\n");
                            Console.Write("Press enter to continue: ");
                            Console.ReadLine();
                        }
                    }
                    break;

                default:
                    break;
                }
                //If the number 5 is pressed, the program closes
            } while (userInput != 5);
        }