using System;
using System.Collections.Generic;
using System.Text;
namespace Joy
{
class Program
{
static void Main(string[] args)
{
const int intmaxspeed = 100;
int intspeed = 0;
try
{
Console.WriteLine("請輸入目前車速:");
intspeed = int.Parse(Console.ReadLine());
if (intspeed > intmaxspeed)
{
throw new overmaxspeed();
}
}
catch (FormatException s)
{
Console.WriteLine(s.ToString());
}
catch (overmaxspeed speed)
{
Console.WriteLine(speed.ToString());
}
Console.ReadLine();
}
class overmaxspeed : ApplicationException
{
string strMessage;
public overmaxspeed()
: base()
{
this.strMessage = "請注意,目前車速過快!!";
}
}
}
}
留言列表