Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to write a program which will allow two players to play "a guess word" game as part of my learning curve in Java. When prompted, player 1 types in a word but the screen displays an asterisk * for each letter in the word. Simply player 1 types a word but the word should be displayed in asterisks rather than characters. I seem to have problem getting this one right.

Is there any method(s) in Stream Buffer or Scanner class that'll allow me to do that above.

thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
313 views
Welcome To Ask or Share your Answers For Others

1 Answer

The intuition that you should intercept input, save original data, and show it masked in the console. You can achieve that by separate thread working on it.

Use this reference http://java.sun.com/developer/technicalArticles/Security/pwordmask/

Magic happens in EraserThread class.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...