Jaypee Hernandez wrote:I have a pdf copy of Head First Java. Based on what is in the book, it is a game (Simple Dot Game), first of all it has 2 classes, a Game class and a DotCom class. First is you initialized an integer array, which will be the placeholder of the dots. There are 3 dots to guessed on which "place" it is. Then the options will be integers like 1,2,3,4,5 you will select one of these and goes the loop. The objective of the game is to guess the location of three cells in the integer array as efficient as possible with fewer guesses i think. In your DotCom class you should initialize the location of the three dots. Then in your code above, make a method but you didn't used it, maybe it will be used for your Game class. The For loop is used whenever a user throws a guess on which array position [from 0-6 i guess] the dots are located. Then if the user guess correctly a place where a dot is, a hit will be counted, until it reaches 3, and then when you guess all the positions of the dots correctly, the "kill" message will come out and then it will print the number of guess you've made. Maybe in a 2v2 game, the winner will be the one with the fewer guess..
Tushar Goel wrote:why you are confused? What part you don't understand? We will help you to understand that part..
Shubham Semwal wrote:I'm not getting the point of traversing the array locationcells after our guess.
Shubham Semwal wrote:@Stefan
And as per code it should be a kill if the user guesses a "2" right ?