using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Page72_2
{
class Program
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("請輸入您的年齡");
try
{
int age = int.Parse(Console.ReadLine());
switch (IsLook(age))
{
case 0: Console.WriteLine("查看成功!溫馨提示:身體雖好可不要多看!謝謝");
break;
case 1:
Console.WriteLine("多大的年紀啊,確定要查看嗎? 【yes/no】");
string yesNo = Console.ReadLine();
if (yesNo == "yes" || yesNo == "YES")
{
Console.WriteLine("少兒不宜,查看成功!");
}
else if (yesNo == "no" || yesNo == "No")
{
Console.WriteLine("少兒不宜,未能查看成功");
}
else
{
Console.WriteLine("你輸得是個什麼玩意?");
}
break;
case -1: Console.WriteLine("小p孩才多大啊,不讓看!!!");
break;
}
}
catch (Exception)
{
Console.WriteLine("您輸入的什麼年齡啊,輸入錯誤!");
}
}
}
public static int IsLook(int age)
{
if (age >= 18)
{
return 0;
}
else if (age < 10)
{
return -1;
}
else if (age >= 10 && age < 18)
{
return 1;
}
return 2;
}
}
}