- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
Latest commit
executable file
·30 lines (25 loc) · 892 Bytes
/
Copy pathGame.java
File metadata and controls
executable file
·30 lines (25 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
packagechap05;
importhelpers.GameHelper;
importjava.util.Scanner;
publicclassGame {
publicstaticvoidmain(String[] args)
{
intnumOfGuesses = 0;
GameHelperhelper = newGameHelper();
SimpleDotComtheDotCom = newSimpleDotCom();
intrandomNum = (int) (Math.random() * 5);
int[] locations = {randomNum, randomNum+1, randomNum+2};
theDotCom.setLocationCells(locations);
booleanisAlive = true;
while (isAlive == true)
{
Stringguess = helper.getUserInput("enter a number");
Stringresult = theDotCom.checkYourself(guess);
numOfGuesses++;
if (result.equals("kill")) {
isAlive = false;
System.out.println("You took " + numOfGuesses + " guesses");
}
}
}
}