c#枚举练习

namespace 枚举

    enum E_sexType

    {
            /// <summary>
            /// 男性
            /// </summary>
        Man,
       /// <summary>
       /// 女性
       /// </summary>
        Woman,

    }
    enum E_occupation
    { /// <summary>
    /// 战士
    /// </summary>
    Warrior,
    /// <summary>
    /// 猎人
    /// </summary>
    Hunter,
    /// <summary>
    /// 法师
    /// </summary>
    Master,
    }

    class program { 

            static void Main (String[] args)
            {
           
            try 
            {
                int atk=0;
                int def=0;
                string skill="";
                E_sexType sextype;
                Console.WriteLine("请选择英雄性别:男性0 女性1");
               sextype=(E_sexType)int.Parse( Console.ReadLine());
                switch(sextype)
                {
                    case E_sexType.Man:
                        atk = 50;
                        def = 100;
                        break;
                    case E_sexType.Woman:
                        atk = 150;
                        def = 20;
                        break;
                }

                E_occupation occupation= new E_occupation();
                Console.WriteLine("请选择英雄职业:战士0 猎人1 法师2");
                occupation = (E_occupation)int.Parse(Console.ReadLine());

                switch (occupation)
                {
                    case E_occupation.Warrior:
                        atk += 20;
                        def += 100;
                        skill = "冲锋";
                        break;
                    case E_occupation.Hunter:
                        atk += 120;
                        def += 30;
                        skill = "假死";
                        break;
                    case E_occupation.Master:
                        atk += 200;
                        def += 10;
                        skill = "奥术攻击";
                        break;

                }

                Console.WriteLine("你选择了{0} ,攻击力{1} ,防御力{2} ,职业技能 {3}。", sextype, atk, def, skill);


            } 
            catch (Exception e) { Console.WriteLine("请输入数字"); }
         
            }
    }
}
 

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值