In case of auto-flushing you probably have sth like:
new PrintWriter(this.server.ge
change that into:
new PrintWriter(this.server.ge
Mark
Main Topics
Browse All TopicsHi Experts
I am designing a MUD game and wanted to include a dance feature, something similar to dance dance revolution but for the keyboard. Unfortunately you cannot use keypress in a telnet session so I opted for an array of strings that are printed to the screen and the user has to type them back.
This is my code
public void dance(){
String input = null;
String[] word = new String[20];
String[] moves = {"up ","up "};
for(int i=0; i< moves.length; i++){
Game.server.out(moves[i]);
try {
input = Game.server.ir.readLine();
word = input.split(" ");
String out = moves[i];
for(int j=0; j<word.length; j++){
String in = word[j];
if(in.equalsIgnoreCase(out
Game.server.out("Cool");
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try{
Thread.sleep(1000);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
It prints the array to the screen and accepts the incoming text but does not seem to compare the values tried all sorts can’t get it to work would appreciate any help.
What I would like is the word to print to the out stream the user enters it into the in stream and if it is right the out stream prints cool or something like that and then prints the next item in the array.
Thanks
Clive
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
That's easy i guess, you can use a 2 dimensional array or a list of arrays.
I'm not sure what you want to randomize, so let's say you have a fixed number of "random sequences", then you can put them all inside an array and pick a random element with:
int index = (int) Math.floor(Math.random()*s
...somearray[index]...
Mark
your way is not possible, since you cannot dynamically bind a number to a variable name like:
String[] randomMoves = (moves + Math.random());
So you need sth like;
String[][] moves= { {"up","left"}
, {"down","up"}
, {"up","right"} };
Now you can access each array with just an integer like:
moves[1] will get the array: {"down","up"}
Mark.
Business Accounts
Answer for Membership
by: ADSLMarkPosted on 2007-03-29 at 13:20:57ID: 18819492
Did you set auto-flush on true, while getting the outputstream?
You could also do:
Game.server.out("Cool");
Game.server.flush();
Mark