Exemplo n.º 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);
            Beast theBeast = new Beast(theNumberGenerator, theLog);


            // Now battle...How do we do that (Hint: You need a loop)
            // YOUR JOB: Insert code here to make theHero and theBeast battle

            while (!theBeast.IsDead() && !theHero.IsDead())
            {
                // The hero deals damage to the beast
                theBeast.ReceiveDamage(theHero.DealDamage());

                if (!theBeast.IsDead())
                {
                    // The beast deals damage to the hero, unless it's dead
                    theHero.ReceiveDamage(theBeast.DealDamage());
                }
            }
            theLog.PrintEntireBattleLog();



            // 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)
            // YOUR JOB: Insert code here to make theHero and theBeast battle

            while (!theBeast.IsDead() && !theHero.IsDead())
            {
                int heroDmg = theHero.DealDamage();
                theBeast.ReceiveDamage(heroDmg);

                if (theBeast.IsDead() == true)
                {
                    break;
                }

                int beastDmg = theBeast.DealDamage();
                theHero.ReceiveDamage(beastDmg);
            }

            theLog.PrintEntireBattleLog();

            // The LAST line of code should be ABOVE this line
        }
Exemplo n.º 3
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);
            Beast theBeast = new Beast(theNumberGenerator, theLog);


            // Now battle...How do we do that (Hint: You need a loop)
            // YOUR JOB: Insert code here to make theHero and theBeast battle


            theLog.PrintEntireBattleLog();

            // The LAST line of code should be ABOVE this line
        }
Exemplo n.º 4
0
 // Create a Hero, using references to a random number generator and a battle log
 public Hero(NumberGenerator generator, BattleLog log)
 {
     this.generator = generator;
     this.log = log;
     Reset();
 }
Exemplo n.º 5
0
 // Create a Hero, using references to a random number generator and a battle log
 public Hero(NumberGenerator generator, BattleLog log)
 {
     this.generator = generator;
     this.log       = log;
     Reset();
 }