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 = "請注意,目前車速過快!!";
            }
        }
    }
}


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Joy 的頭像
    Joy

    正Man's World

    Joy 發表在 痞客邦 留言(0) 人氣()