Hi, i've been helping my younger brother to write this pretty simple client/server lottery program in Java for his Uni's coursework,, but since i dont program in java, i got a little problem.... Basically i've got my client done and only got a little problem with my server. The client should get user input for 6 numbers, then store them in a string and pass to the server through a socket connection, a server then generates 6 random numbers, compares them with recie3ved string and sends the result back to client. Well i get user input, store the files in the string, pass them to the server, grnerate random numbers, but the problem i have is that i cant compare the 2. I could just compare 2 strings but that wouldn't make sence for the lottery application. What i think i need is to extract integers from the string that was sent from the client and compare each integer with random numbers.
This is the user input from the client. The server recieves the string "guesses":
for (int i=1;i<=6;i++) {
String input = JOptionPane.showInputDialog(message);
int guess = Integer.parseInt(input);
guesses += guess + " ";
}
Now here's the servers bit, it generates numbers and then i need to compare them, but i dont know how... Please help.
for (int i=1;i<=6;i++) {
//////Here i need to convert recieved "guesses" string into integers//////////
int number = randomInteger(0,99);
count += ((whatever we gonna call the extracted inegers) == number) ? 1 : 0;
numbers += number + " ";
}
Thank you
This is the user input from the client. The server recieves the string "guesses":
for (int i=1;i<=6;i++) {
String input = JOptionPane.showInputDialog(message);
int guess = Integer.parseInt(input);
guesses += guess + " ";
}
Now here's the servers bit, it generates numbers and then i need to compare them, but i dont know how... Please help.
for (int i=1;i<=6;i++) {
//////Here i need to convert recieved "guesses" string into integers//////////
int number = randomInteger(0,99);
count += ((whatever we gonna call the extracted inegers) == number) ? 1 : 0;
numbers += number + " ";
}
Thank you