SimpleDotComGame.java


SUBMITTED BY: joelc608

DATE: Jan. 2, 2016, 11:07 p.m.

FORMAT: Java

SIZE: 660 Bytes

HITS: 2269

  1. public class SimpleDotComGame {
  2. public static void main(String[] args) {
  3. int numOfGuesses = 0;
  4. GameHelper helper = new GameHelper();
  5. SimpleDotCom theDotCom = new SimpleDotCom();
  6. int randomNum = (int) (Math.random() * 5);
  7. int[] locations = {randomNum, randomNum + 1, randomNum + 2};
  8. theDotCom.setLocationCells(locations);
  9. boolean isAlive = true;
  10. while(isAlive == true) {
  11. String guess = helper.getUserInput("enter a number");
  12. String result = theDotCom.checkYourself(guess);
  13. numOfGuesses++;
  14. if (result.equals("kill"))
  15. isAlive = false;
  16. System.out.println("you took " + numOfGuesses + " guesses.");
  17. }
  18. }
  19. }

comments powered by Disqus