using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace BankSystem1
{
    class Program
    {
        static string UserName = "gsw";
        static string Password = "111111";
        static double Money = 1000.00;
        static void Main(string[] args)
        {
            Console.WriteLine("欢迎使用光大银行");
            Console.Title = "光大银行";
            GetPassword();
        }
        static void GetPassword()
        {
            int mark = 3;
            while (mark>0)
            {
                string password = "";
                Console.WriteLine("用户名:");
                string temun = Console.ReadLine();

                Console.WriteLine("密码:");

                for (int i = 0; i < 6; i++)

                {
                    ConsoleKeyInfo ski = Console.ReadKey(true);
                    Console.Write("*");
                    if (int.Parse(ski.KeyChar.ToString()) < 6)
                    {
                        password = password + ski.KeyChar.ToString();
                    }
                }
                Console.ReadKey(true);
                    if (UserName == temun && Password == password)
                    {
                        DengLu();
                        return;
                  
                }
                    else
                    {
                        mark--;
                        Console.WriteLine("用户名或密码错误,还余{0}次输入机会,请重新输入:",mark);
                       
                      
                    }
            }
           
           
        }
        static void SetColor()
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("返回请按任意键!");
            Console.ResetColor();
        }
        static void DengLu()
        {
            {
                while (true)
                {
                    Console.WriteLine(UserName + "欢迎登录!");
                    Console.Clear();
                    Console.WriteLine("1、余额查询  2、存款  3、取款  4、转帐 5、退出");
                    switch (Console.ReadLine())
                    {
                        case "1":
                            SelectMoney();
                            break;
                        case "2":
                            InMoney();
                            break;
                        case "3":
                            OutMoney();
                            break;
                        case "4":
                            ZhuangZhang();
                            break;
                        case "5":
                            return;
                    }
                }

            }

        }
        static void SelectMoney()
        {
            Console.WriteLine("您的余额为:{0:c}", Money);
            SetColor();
            Console.ReadKey(true);
        }
        static void InMoney()
        {
            Console.WriteLine("请输入要存入的金额:");
            double temmoney = double.Parse(Console.ReadLine());
            Money += temmoney;
            Console.WriteLine("操作成功!当前余额为:{0:c}", Money);
            SetColor();
            Console.ReadKey(true);
        }
        static void OutMoney()
        {
            Console.WriteLine("请输入要取出的金额:");
            double OutMoney = double.Parse(Console.ReadLine());
            if (OutMoney <= Money)
            {
                Money -= OutMoney;
                Console.WriteLine("操作成功!当前余额为:{0:c}", Money);
                SetColor();
                Console.ReadKey(true);
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("您的余额不足,将返回主菜单!");
                Console.ResetColor();
                Thread.Sleep(1000);
            }
        }
        static void ZhuangZhang()
        {
            Console.WriteLine("请输入要转入的帐户名:");
            string UserName1 = Console.ReadLine();
            Console.WriteLine("请输入要转入的金额:");
            double ZhMoney = double.Parse(Console.ReadLine());
            if (ZhMoney <= Money)
            {
                Money -= ZhMoney;
                Console.WriteLine("操作成功!当前余额为:{0:c}", Money);
                SetColor();
                Console.ReadKey(true);
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("您的余额不足,将返回主菜单!");
                Console.ResetColor();
                Thread.Sleep(1000);
            }
        }
    }
}