美文网首页
2018-12-27

2018-12-27

作者: 柏建春 | 来源:发表于2018-12-27 09:43 被阅读0次

#代码

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication4

{

    class Program

    {

        static void Main(string[] args)

        {

            bool huida = false;

            bool biaoshi = false;

            string a ="0";

            string b="0";

            try

            {

                do

                {

                    Console.WriteLine("*****欢迎进入奖客富翁系统*****");

                    Console.WriteLine("1注册");

                    Console.WriteLine("2登录");

                    Console.WriteLine("3抽奖");

                    Console.WriteLine("******************************");

                    Console.WriteLine("请选择菜单:");

                    huida = false;

                    int num = Convert.ToInt32(Console.ReadLine());

                    switch (num)

                    {

                        case 1:

                            Console.WriteLine("[讲课富翁系统>注册]");

                            Console.WriteLine("请填写个人注册信息:");

                            Console.WriteLine("用户名:");

                            a = Console.ReadLine();

                            Console.WriteLine("密码:");

                            b = Console.ReadLine();

                            System.Random Random = new System.Random();

                            int result = Random.Next(1000, 9999);

                            Console.WriteLine("注册成功,请记好您的会员卡号");

                            Console.WriteLine("用户名\t密码\t会员卡号");

                            Console.WriteLine("{0}\t{1}\t{2}", a, b, result);

                            biaoshi = true;

                            break;

                        case 2:

                            int count = 1;

                            if (biaoshi == true)

                            {

                                Console.WriteLine("[讲课富翁系统>登录]");

                                do

                                {

                                    Console.WriteLine("请输入用户名");

                                    string shuru1 = Console.ReadLine();

                                    Console.WriteLine("请输入密码");

                                    string shuru2 = Console.ReadLine();

                                    if (shuru1 == a && shuru2 == b)

                                    {

                                        Console.WriteLine("欢迎您:{0}", a);

                                        count = 3;

                                    }

                                    else

                                    {

                                        Console.WriteLine("用户名或密码错误,请重新输入");

                                    }

                                    count++;

                                } while (count <= 3);

                            }

                            else

                            {

                                Console.WriteLine("您还未注册,请先注册");

                                break;

                            }

                            break;

                        case 3:

                            if (biaoshi == true)

                            {

                                Console.WriteLine("[讲课富翁系统>抽奖]");

                            }

                            else

                            {

                                Console.WriteLine("您还未注册,请先注册");

                            }

                            break;

                        default:

                            Console.WriteLine("输入有误,程序结束");

                            continue;

                    }

                    Console.WriteLine("继续吗(y/n)");

                    string huida0 = Console.ReadLine();

                    if (huida0 == "y")

                    {

                        huida = true;

                    }

                    else

                    {

                        Console.WriteLine("您选择退出,程序结束.");

                        continue;

                    }

                } while (huida == true);

            }

            catch

            {

                Console.WriteLine("您输入有误");

            }

            Console.ReadKey();

        }

    }

}

#效果

相关文章

网友评论

      本文标题:2018-12-27

      本文链接:https://www.haomeiwen.com/subject/iwnllqtx.html