Exemple #1
0
        public void MyCode()
        {
            // The FIRST line of code should be BELOW this line

            NumberGenerator theNumberGenerator = new NumberGenerator();
            BattleLog       theLog             = new BattleLog();

            Hero  theHero  = new Hero(theNumberGenerator, theLog, 100, 10, 30);
            Beast theBeast = new Beast(theNumberGenerator, theLog, 90, 10, 25);

            // While both battle participants are alive (i.e. not dead)
            while (!theHero.Dead && !theBeast.Dead)
            {
                // Hero hits Beast
                int damageByHero = theHero.DealDamage();
                theBeast.ReceiveDamage(damageByHero);

                // If Beast is still alive: Beast hits Hero
                if (!theBeast.Dead)
                {
                    int damageByBeast = theBeast.DealDamage();
                    theHero.ReceiveDamage(damageByBeast);
                }
            }

            theLog.PrintLog();

            // The LAST line of code should be ABOVE this line
        }
        public void MyCode()
        {
            // The FIRST line of code should be BELOW this line

            NumberGenerator theNumberGenerator = new NumberGenerator();
            BattleLog       theLog             = new BattleLog();

            Hero  theHero  = new Hero(theNumberGenerator, theLog);
            Beast theBeast = new Beast(theNumberGenerator, theLog);

            // Now battle...How do we do that (Hint: You need a loop)

            while (!theHero.Dead && !theBeast.Dead)
            {
                if (!theHero.Dead)
                {
                    theBeast.ReceiveDamage(theHero.DealDamage());
                }
                if (!theBeast.Dead)
                {
                    theHero.ReceiveDamage(theBeast.DealDamage());
                }
            }
            theLog.PrintLog();


            // The LAST line of code should be ABOVE this line
        }
        public void MyCode()
        {
            // The FIRST line of code should be BELOW this line

            NumberGenerator theNumberGenerator = new NumberGenerator();
            BattleLog       theLog             = new BattleLog();

            Hero  theHero  = new Hero(theNumberGenerator, theLog, 100, 10, 30);
            Beast theBeast = new Beast(theNumberGenerator, theLog, 90, 10, 25);

            // Så længe begge deltagere er i live
            while (!theHero.Dead && !theBeast.Dead)
            {
                // Den ene slår den anden
                int damageByHero = theHero.DealDamage();
                theBeast.ReceiveDamage(damageByHero);

                // Den anden slås den første, hvis den anden ikke er død i mellemtiden
                if (!theBeast.Dead)
                {
                    int damageByBeast = theBeast.DealDamage();
                    theHero.ReceiveDamage(damageByBeast);
                }
            }

            theLog.PrintLog();

            // The LAST line of code should be ABOVE this line
        }
        public void MyCode()
        {
            // The FIRST line of code should be BELOW this line

            NumberGenerator theNumberGenerator = new NumberGenerator();
            BattleLog       theLog             = new BattleLog();

            Hero  theHero  = new Hero(theNumberGenerator, theLog);
            Beast theBeast = new Beast(theNumberGenerator, theLog);

            // Now battle...How do we do that (Hint: You need a loop)

            theLog.PrintLog();

            // The LAST line of code should be ABOVE this line
        }