美文网首页
2018-12-27(五)实现幸运抽奖 1. 需求说明 (1)

2018-12-27(五)实现幸运抽奖 1. 需求说明 (1)

作者: 拾起_518 | 来源:发表于2018-12-27 16:07 被阅读0次

    实现幸运抽奖

    1. 需求说明
      (1) . 登录成功后,用户选择幸运抽奖菜单,进入幸运抽奖功能
      (2) . 输入会员卡号,系统生成5个4位随机数作为幸运数字
      (3) . 如果会员卡号是其中之一,则成为本日幸运会员;否则不是幸运会员

          int max = 99999;
          int min = 1000;
          Random rd = new Random();
          rd.Next(min, max);
          int a = 0;
          int id = 0;
          string user = "";
          string key = "";
          string b = "";
          Console.WriteLine("*****欢迎进入奖客富翁系统*****");
          Console.WriteLine("           1.注册");
          Console.WriteLine("           2.登录");
          Console.WriteLine("           3.抽奖");
          Console.WriteLine("******************************");
          Console.WriteLine("请选择菜单:");
          a = Convert.ToInt32(Console.ReadLine());
          switch (a)
          {
              case 1:
                  Console.WriteLine("[奖客富翁系统>注册]");
                  Console.WriteLine("请填写用户注册信息:");
                  Console.WriteLine("用户名:");
                  user = Console.ReadLine();
                  Console.WriteLine("密码:");
                  key = Console.ReadLine();
                  Console.WriteLine("注册成功,请记好你的会员卡号");
                  Console.WriteLine("用户名\t\t密码\t\t会员卡号");
                  Console.WriteLine("{0}\t\t{1}\t\t{2}", user, key, rd.Next(min, max));
                  Console.WriteLine("继续吗?(y/n)");
                  b = Console.ReadLine();
                  break;
              case 2:
                  Console.WriteLine("[奖客富翁系统>登录]");
                  Console.WriteLine("请输入用户名:");
                  user = "admin";
                  key = "123456";
                  string yonghu = Console.ReadLine();
                  Console.WriteLine("请输入密码:");
                  string mima = Console.ReadLine();
                  for (int i = 0; i < 4; i++)
                  {
                      if (user == yonghu & key == mima)
                      {
                          Console.WriteLine("欢迎您:{0}", yonghu);
                          break;
                      }
                      else
                      {
                          Console.WriteLine("你还剩{0}次机会", 3 - i);
                          continue;
                      }
                  }
                  break;
              case 3:
                  Console.WriteLine("[奖客富翁系统>抽奖]");
                  Console.WriteLine("请输入你的卡号");
                  id = Convert.ToInt32(Console.ReadLine());
                  Console.WriteLine("今日的幸运数字为:");
                  for (int i = 0; i < 4; i++)
                  {
                      Console.WriteLine(rd.Next(min, max));
                  }
                  if (rd.Next(min, max) == id)
                  {
                      Console.WriteLine("恭喜!你是本日的幸运会员!");
                  }
                  else
                  {
                      Console.WriteLine("抱歉!您不是本日的幸运会员!");
                  }
                  break;
          }
          Console.WriteLine("继续吗?(y/n)");
          b = Console.ReadLine(); switch (b)
          {
              case "n":
                  Console.WriteLine("系统退出,谢谢使用");
                  break;
              case "y":
                  Console.WriteLine("");
                  break;
          }
          Console.ReadKey();

    相关文章

      网友评论

          本文标题:2018-12-27(五)实现幸运抽奖 1. 需求说明 (1)

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