Beispiel #1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            int         choose;
            AccountList accountList = new AccountList();

            while (true)
            {
                Menu();
                choose = Int32.Parse(Console.ReadLine());
                switch (choose)
                {
                case 1:
                    accountList.CreateAccount();
                    break;

                case 2:
                    accountList.ShowData();
                    break;

                case 3:
                    Console.WriteLine("THOÁT CHƯƠNG TRÌNH RỒI! Em trai :D");
                    return;

                default:
                    Console.WriteLine("CHỌN SAI RỒI NHÉ!");
                    break;
                }
            }
        }
Beispiel #2
0
        static void ChooseMenu(int choose)
        {
            Console.Clear();
            switch (choose)
            {
            case 1:
                AccountList.CreateAccount();
                Console.WriteLine("Create finish...");
                break;

            case 2:
                Console.WriteLine("Enter id want to put in/ draw money: ");
                int    id;
                string str = Console.ReadLine();
                while (!int.TryParse(str, out id) || id < 0)
                {
                    Console.Write("Enter again! ");
                    str = Console.ReadLine();
                }
                bool check = false;
                foreach (var item in AccountList.accounts)
                {
                    if (item.AccountId == id)
                    {
                        Console.WriteLine("Enter money:");
                        int money;
                        str = Console.ReadLine();
                        while (!int.TryParse(str, out money) || money < 0)
                        {
                            Console.Write("Enter again! ");
                            str = Console.ReadLine();
                        }

                        Console.WriteLine("Want to draw (press 1)/ put in (press 2): ");
                        int number;
                        str = Console.ReadLine();
                        while (!int.TryParse(str, out number) || number > 2 || number < 1)
                        {
                            Console.Write("Enter again! ");
                            str = Console.ReadLine();
                        }
                        switch (number)
                        {
                        case 1:
                            item.Balance -= money;
                            break;

                        case 2:
                            item.Balance += money;
                            break;
                        }
                        check = true;
                    }
                    if (check)
                    {
                        Console.WriteLine("Succeeded.");
                    }
                    else
                    {
                        Console.WriteLine("Not found ID.");
                    }
                }
                AccountList.PayInto();
                break;

            case 3:
                AccountList.ShowData();
                break;

            case 4:
                Console.WriteLine("Exit the program.");
                Environment.Exit(Environment.ExitCode);
                break;
            }
            DisplayMenu();
        }