コード例 #1
0
        static void Main(string[] args)
        {
            string answer;

            /*
             * Customer customerbalance1 = new Customer();
             * Customer customerbalance2 = new Customer();
             * Customer customerbalance3 = new Customer(); */

            Console.WriteLine("Welcome to JorreCapitalBank!");

            Console.WriteLine("");
            Console.WriteLine("Choose one of the following options.");
            Console.WriteLine("");
            while (true)
            {
                Console.WriteLine("1 : Add customer");
                Console.WriteLine("2 : Show customer");
                Console.WriteLine("3 : Remove idiets from bank");
                Console.WriteLine("4 : Add money to account");
                Console.WriteLine("");
                Console.Write("Skriv ditt val: ");
                answer = Console.ReadLine();

                switch (answer)
                {
                case "1":
                    Console.Clear();
                    Console.WriteLine("Add customer");
                    addCustomer();
                    Console.Clear();
                    break;

                case "2":
                    Console.Clear();
                    foreach (var Customer in customerbalance)
                    {
                        Console.WriteLine("User: {0}", Customer.name);
                    }
                    Console.ReadLine();
                    Console.Clear();
                    break;

                case "3":
                    Console.Clear();
                    Customer.showCustomer();
                    int retrieve = 1;
                    retrieve = Convert.ToInt32(Console.ReadLine());
                    int count = 1;
                    foreach (var customer in customerbalance)
                    {
                        if (retrieve == count)
                        {
                            customerbalance.Remove(customer);
                            break;
                        }
                        count++;
                    }
                    Console.Clear();
                    break;

                case "4":
                    Console.WriteLine("would you like to see a list of users? [Y]es or [N]o");
                    answer = Console.ReadLine();
                    if (answer == "Y" && answer == "y")
                    {
                        Customer.showCustomer();
                    }
                    else if (answer == "N" && answer == "n")
                    {
                        Console.WriteLine("Then simply write the users ID");
                        Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine("please enter correctly");
                    }

                    Console.WriteLine("In which account would you like to make an transaction?");
                    Console.WriteLine("srry we have technical problems");
                    Console.Clear();
                    break;
                }
            }



            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            string answer;

            /*
             * Customer customerbalance1 = new Customer();
             * Customer customerbalance2 = new Customer();
             * Customer customerbalance3 = new Customer(); */

            Console.WriteLine("Welcome to JorreCapitalBank!");
            Console.WriteLine("");
            Console.WriteLine("Choose one of the following options.");
            Console.WriteLine("");
            while (true)
            {
                Console.WriteLine("1 : Add customer");
                Console.WriteLine("2 : Show customer");
                Console.WriteLine("3 : Remove idiets from bank");
                Console.WriteLine("4 : Add money to account");
                Console.WriteLine("5 : Show transactions for users");
                Console.Write("Skriv ditt val: ");
                answer = Console.ReadLine();

                switch (answer)
                {
                case "1":
                    Console.Clear();
                    Console.WriteLine("Add customer");
                    addCustomer();
                    Console.Clear();
                    break;

                case "2":
                    Console.Clear();
                    foreach (var Customer in customerbalance)
                    {
                        Console.WriteLine("User: {0}", Customer.name);
                    }
                    Console.ReadLine();
                    Console.Clear();
                    break;

                case "3":
                    Console.Clear();
                    Customer.showCustomer();
                    int retrieve = 1;                               // What number are you looking to delete
                    retrieve = Convert.ToInt32(Console.ReadLine()); // converting readline method tov accept integer
                    int countIndex  = 1;
                    int indexDelete = -1;

                    foreach (var customer in customerbalance)
                    {
                        if (retrieve == countIndex)
                        {
                            indexDelete = countIndex;     // The current elements index number is stored in "indexDelete"
                            break;
                        }
                        countIndex++;
                    }
                    if (indexDelete != -1)
                    {
                        customerbalance.RemoveAt(indexDelete);
                    }

                    Console.Clear();
                    break;

                case "4":
                    Customer transaction = new Customer();     // Creat an object that can be sent to a list later on
                    // Save the name of the user making an transaction
                    Console.WriteLine("In which account would you like to make an transaction?");
                    answer           = Console.ReadLine();
                    transaction.name = answer;

                    // save the time of the current transaction
                    Console.WriteLine("what time is it");
                    answer           = Console.ReadLine();
                    transaction.time = answer;

                    // Save the amount of money
                    Console.WriteLine("how much money");
                    answer             = Console.ReadLine();
                    transactions.money = answer;
                    Console.Clear();
                    break;

                case "5":
                    customerbalance.ShowTransactions();
                    break;
                }
            }



            Console.ReadKey();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            /*
             * Customer customerbalance1 = new Customer();
             * Customer customerbalance2 = new Customer();
             * Customer customerbalance3 = new Customer(); */

            Console.WriteLine("Welcome to JorreCapitalBank!");

            Console.WriteLine("");
            Console.WriteLine("Choose one of the following options.");
            Console.WriteLine("");
            while (true) // evighetsloop för programmet
            {
                Console.WriteLine("1 : Add customer");
                Console.WriteLine("2 : Show customer");
                Console.WriteLine("3 : Remove customer from bank");
                Console.WriteLine("4 : Exit bank");
                Console.WriteLine("");
                Console.Write("Write your choice: ");
                string answer = Console.ReadLine();
                try
                {
                    switch (answer)
                    {
                    // case 1 lägger till användare i banken
                    case "1":
                        Console.Clear();
                        Console.WriteLine("Add customer");
                        AddCustomer();
                        Console.Clear();
                        break;

                    // case 2 visar befintliga användare
                    case "2":
                        Console.Clear();
                        foreach (var Customer in customerbalance)
                        {
                            Console.WriteLine("User: {0}", Customer.name);
                        }
                        Console.ReadLine();
                        Console.Clear();
                        break;

                    //case 3 tar bort användare för banken
                    case "3":

                        Console.Clear();
                        Customer.showCustomer();
                        Console.WriteLine("");
                        Console.Write("Which customer do you want to remove: ");
                        DeleteCustomer();
                        Console.Clear();
                        break;

                    case "4":
                        Console.Clear();

                        break;

                    default:
                        throw new Exception();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error, Try using number that exist");
                    Console.ReadKey();
                    Console.Clear();
                }
            }



            Console.ReadKey();
        }