码迷,mamicode.com
首页 > Web开发 > 详细

.NET第二周的学习情况

时间:2015-04-07 19:40:10      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

现在我们开始学习面向对象的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);
        }

等等、、、、

.NET第二周的学习情况

标签:

原文地址:http://www.cnblogs.com/yangxingxiu/p/4399075.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!