public static void main(String[] orgs) { int numOfGuesses = 0; GameHelper helper = new GameHelper(); SimpleDotCom theDotCom = new SimpleDotCom(); int startNum = (int) (Math.random() * 5); int[] locations = {startNum, startNum + 1, startNum + 2}; theDotCom.setLocationCells(locations); boolean isAlive = true; while (isAlive == true) { String guess = helper.getUserInput("enter a number"); String result = theDotCom.checkYourself(guess); numOfGuesses++; System.out.println(numOfGuesses); if (result.equals("kill")) { isAlive = false; System.out.println("You took " + numOfGuesses + " guesses."); } } }
public static void main(String[] args) { System.out.println("Welcome, Please keep guessing till you get a Kill!!"); GameHelper helper = new GameHelper(); SimpleDotCom theDotCom = new SimpleDotCom(); int randomNum = (int) (Math.random() * 5); ArrayList locations = new ArrayList(); locations.add(randomNum); locations.add(randomNum + 1); locations.add(randomNum + 2); theDotCom.setLocationCells(locations); boolean isAlive = true; while (isAlive == true) { String guess = helper.getUserInput("Enter a number"); String result = theDotCom.checkYourself(guess); System.out.println(result); numOfGuesses++; if (theDotCom.a == 1) { isAlive = false; } // close if } // close while }