if its successful,i want to end the program.if its not,to generate a random number and check with it.... i dont get the desired output.
class dotcomm
{
public static void main(
String[] args)
{
dd d =new dd();
d.game();
}
}
class dd
{
int hit=0;
int[] locations = {2,3,4};
void game()
{
while(true)
{
int userg=(int)(Math.random()*4);
System.out.println("the guess is"+userg);
for(int num:locations)
{
if(userg==num)
{
System.out.println("successful");
//hit++;
//System.out.println("the num of hits ="+ hit);
break;
}
}
System.out.println("does not match,TRY AGAIN");
}
}
}