2019-01-02
#代码
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;
bool biaoshi2 = false;
int result = 1000;
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();
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);
biaoshi2 = true;
}
else
{
Console.WriteLine("您还未注册,请先注册");
}
break;
case 3:
if (biaoshi == true)
{
if (biaoshi2 == true)
{
Console.WriteLine("[讲课富翁系统>抽奖]");
Console.WriteLine("请输入卡号:");
int result1 = Convert.ToInt32(Console.ReadLine());
if (result1 == result)
{
System.Random Random1 = new System.Random();
int m1 = Random1.Next(1000, 9999);
int m2 = Random1.Next(1000, 9999);
int m3 = Random1.Next(1000, 9999);
int m4 = Random1.Next(1000, 9999);
Console.WriteLine("本日的幸运数字为:{0}{1}{2}{3}{4}", m1, m2, m3, m4);
if (result1 == m1 || result1 == m2 || result1 == m3 || result1 == m4)
{
Console.WriteLine("恭喜您成为幸运用户");
}
else
{
Console.WriteLine("抱歉!您今天不是幸运会员!");
}
}
else
{
Console.WriteLine("输入错误");
break;
}
}
else
{
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();
}
}
}
#效果