作业1

#要求

用户进入游戏平台后,可以选择喜爱的游戏,程序运行结果如下:


#程序

namespace ConsoleApplication14

{

    class Program

    {

        static void Main(string[] args)

        {

            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();


        }

    }

}

效果


你可能感兴趣的:(作业1)