.NET第二周的学习情况

现在我们开始学习面向对象的3天,我发现面向对象好绕;

eg: public int Baoji
        {
            get
            {
                return baoji;
            }
            set
            {
                baoji = value;
                if (baoji < 0)
                {
                    baoji = 0;
                }
                if (baoji > 100)
                {
                    baoji = 100;
                }
            }
        }
        public void Attackmonster(monster  m)
        { Console.ForegroundColor = ConsoleColor.Magenta;
            Random rad = new Random();//随机数
            int num = rad.Next(1, 101);//随机数值
            //检查是否被闪避
            if (num <= m.Shanbi)
            {
                Console.WriteLine("对不起!!攻击无效,聪明的怪兽轻而易举的躲开了你的攻击");
                return;
            }
            int shanhai = Attack -m.Deface;
            shanhai = shanhai  < 1 ? 1 : shanhai ;
            //检查是否暴击
            num = rad.Next(1, 101);
            if (num <= Baoji)
            {
                shanhai  *= 2;
                Console.Write("暴击!");
            }
           
            m.Shengmingli -= shanhai;
          
            Console.WriteLine("英雄烈猛的攻击了怪兽,使怪兽受了{0}点伤害,怪兽剩余生命力:{1}", shanhai, m.Shengmingli);
        }

等等、、、、

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。