题目
练习一:选择游戏
(一) 需求说明
用户进入游戏平台后,可以选择喜爱的游戏,程序运行结果如下:

代码
Console.WriteLine("欢迎进入魔法师迷你游戏平台");
Console.WriteLine("请选择你感兴趣的游戏");
Console.WriteLine("****************************************");
Console.WriteLine(@"
1.斗地主
2.斗牛
3.泡泡龙
4.连连看");
Console.WriteLine("****************************************");
Console.WriteLine("请选择你想玩的游戏,并输入对应的序号:( )例如:2");
string shuzi = Console.ReadLine();
try
{
int xuhao = Convert.ToInt32(shuzi);
switch(shuzi)
{
case "1":
Console.WriteLine("您已成功经入斗地主房间!");
break;
case "2":
Console.WriteLine("您已成功进入斗牛房间!");
break ;
case "3":
Console.WriteLine("您已成功进入泡泡龙房间!");
break;
case "4":
Console.WriteLine("您已成功进入连连看房间!");
break;
}
}
catch
{
Console.WriteLine("您的打开方式有误噢,请注意输入的格式!程序退出!");
}
Console.ReadKey();
效果图


网友评论