Hi im working on an assignment "Word guessing game". any1 who can help me or who already made this plzzz send me. the requirements are user will try to guess a word that system randomly generates. his tries will be responded as Example
"Mohsin" (The guessing word) Mhgsah (user types) 11 (System response)
these digits shows the 1 = position of the accurate char. and other 1= correct char found in the string
the main thing that is disturbing .. is how to make this through the network api. mean users can play it on a network. any1 who can do it plzzz help me. i'll be very thankful
I'd break this into very small problems. Do you know how to generate a string of random characters? Do you know the compare rules that will give you the answer 11? Get these things working in a simple program that takes a guess word from the console before you worry about the network part.
AFTER those things are working, take a look at Sun's All About Sockets lessons. Run the examples down through the "client/server pair" and you'll start to see how to introduce the network. You might double check with your instructor if using sockets this way is ok.
If you get stuck, please post little bits of code as you go. Keep us posted on how it goes.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
This is "mastermind", and you should be able to find lots of examples of this on the internet. But I would say you would need to use the String.charAt() function in a loop to look at each letter.
for each letter, but not bigger than the length of the shorter string, if secret one matched guess at same place add one to your 'perfect' counter remove the letter from both (so not to second count it) back-off the counter by one, since you removed the letter else if this secret letter matched anywhere in the guess (indexOf()>-1) add one to your 'wrong position' counter
So String.substring(0,i) will take the first i characters of the string, and String.substring(i+1) will start at i+1 and go to the end. String.charAt(i) will give you a character you can compare.