第八课

2018-12-27  本文已影响0人  怡壹

一、
Console.WriteLine("欢迎进入魔法游戏厅");
Console.WriteLine("请选择您喜爱的游戏:");
Console.WriteLine("****************************************");
Console.WriteLine(@"
1.斗地主
2.斗牛
3.泡泡龙
4.连连看");
Console.WriteLine("****************************************");
Console.Write("请选择:");
string str_num = Console.ReadLine();
try
{
int num = Convert.ToInt32(str_num);
switch (num)
{
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();

二、
int n = 1;
int count = 0;
string answer = "";
do { Console.Write("您正在玩第{0}局,成绩为:", n);
string str_score = Console.ReadLine();
int score = Convert.ToInt32(str_score);
if (score > 80)
{
count++;
}
n++;
if (n > 5)
{
Console.WriteLine("游戏结束");
}
else
{
Console.Write("\n继续玩下一局吗?(yes/no)");
answer = Console.ReadLine();
if ("no" == answer)
{
Console.Write("\n您已经中途退出程序了");
break;
}
else
{
Console.WriteLine("进入一局");
}
}
}
while (n <= 5);
double rate = count / 5.0;
if (n > 5)
{
if (rate > 0.8)
{
Console.WriteLine("恭喜,通过一级");
}
else if (rate > 0.6)
{
Console.WriteLine("通过二级");
}
else
{
Console.WriteLine("\n对不起,你未能晋级,继续加油吧~");
}
}
else
{
Console.WriteLine("对不起,你没有完成游戏,不能晋级,继续加油努力");
}
Console.ReadKey();

上一篇下一篇

猜你喜欢

热点阅读