Package dojo.trivia.a20120505cr4.runner

Source Code of dojo.trivia.a20120505cr4.runner.GameRunner

package dojo.trivia.a20120505cr4.runner;

import java.util.Random;

import dojo.trivia.a20120505cr4.Game;


public class GameRunner {

   private static boolean notAWinner;

   public static void main(String[] args) {
      play(new Random());
   }

   // reorder sequence
   // extract method
   public static void play(Random rand) {
      Game aGame = new Game();

      aGame.addPlayer("Chet");
      aGame.addPlayer("Pat");
      aGame.addPlayer("Sue");

      do {

         int diceCast = rand.nextInt(5) + 1;
         aGame.moveCurrentPlayerWith(diceCast);

         boolean correctAnswer = rand.nextInt(9) != 7;
         if (correctAnswer) {
            notAWinner = aGame.currentPlayerGaveCorrectAnswer();
         } else {
            notAWinner = aGame.currentPlayerGaveWrongAnswer();
         }

      } while (notAWinner);
   }
}
TOP

Related Classes of dojo.trivia.a20120505cr4.runner.GameRunner

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.