Game introduction, we put the site named Dotcom, put it in a Heng lie in the 3 lattice, the player input location to guess the location of the site is stored, guessed for hit, if three squares are guessed as kill, no guess for Miss.
In Jane's Edition we have fixed these.
1 Public classsimpledotcom {2 int[] locationcells;3 intNumofhits = 0;4 5 Public voidSetlocationcells (int[] locs) {6 intGuess =Integer.parseint (stringguess);7String result = "Miss";8 for(intcell:locationcells) {9 if(Guess = =cell) {Tenresult = "hit"; Onenumofhits++; A Break; - } - } the if(Numofhits = =locationcells.length) { -result = "Kill"; - } - System.out.println (result); + returnresult; - } +}
Public class simpledotcomtestdrive{ publicstaticvoid main (String [] args) { New simpledotcom (); int [] locations = {2,3,4}; Dot.setlocationcells (locations); = "2"; = dot.checkyourself (userguess);} }
The design of the simple version attack website game