Synchronization of old projects
Part1
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
Random r = new Random();
|
||||
int bossHealth = 20;
|
||||
int bossDefense = 10;
|
||||
int round = 1;
|
||||
try
|
||||
{
|
||||
Console.WriteLine("游戏开始");
|
||||
while (true)
|
||||
{
|
||||
int attack = r.Next(8, 13);
|
||||
Console.WriteLine("当前第{0}回合",round);
|
||||
if (attack >= bossDefense)
|
||||
{
|
||||
bossHealth -= attack - bossDefense;
|
||||
Console.WriteLine("你攻击了BOSS,造成了" + attack + "点伤害\n" + "BOSS剩余血量:" + bossHealth);
|
||||
}else
|
||||
{
|
||||
Console.WriteLine("你的攻击被BOSS防御住了,造成了0点伤害");
|
||||
}
|
||||
round++;
|
||||
if (bossHealth <= 0)
|
||||
{
|
||||
Console.WriteLine("你打赢了BOSS,共使用了{0}回合",round-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("错误代码: " + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Console.WriteLine("游戏结束");
|
||||
}
|
||||
Reference in New Issue
Block a user