Ok, I am typing up a program in which will play hangman with a user. 

I have done most of the program, but I have to let the program randomly choose a word from the list of words stored in your array. 

Afterwards, it should clear the screen and display a series of asterisks to represent the letters to be guessed. 

Then, display one asterisk for each letter in the chosen word. When displaying the asterisks, make sure you place a space between each asterisk to make it easier to read. See the technical notes below for information about clearing the screen.

Two lines below the asterisks, that should show the user the number of guesses left. The game begins with 8 guesses.

Next, I should allow the user to enter a letter. The user should be able to enter upper or lowercase letters. 

Compare the letter against the ones in the solution. If the letter is in the solution, it should replace the appropriate asterisk(s) with the guessed letter and then redraw the screen (clear the screen, then rewrite the information back to the screen). 

If the guessed letter is not in the solution, it should decrement the number of guesses left and redraw the scree

So, my question is how do I do the asterisks part?

Here's what I have so far,

import java.io.*;
import java.util.*;

public class Hangman {

	public static void main(String[] args) {
	Scanner kbd = new Scanner(System.in);
	String enter;
	Scanner inStream = null;	
	String filename = "dictionary.txt";
	System.out.print("This is a word guessing game. A word will be selected at random and kept hidden." + '\n' + "You will try to figure out the secret word by guessing letters which you think are in the" + '\n' + "word. You will guess one letter at a time. If the letter you guess is correct, the" + '\n' + "position(s) of the letter in the secret word will be shown. You will be allowed 8 wrong" + '\n' + "guesses. If you gues incorrectly 8 times, you lose the game. If you guess all of the" + '\n' + "letters in the word, you win." + '\n');
	System.out.println('\n' + "Press enter to continue");
	enter = kbd.next();
		inStream = new Scanner (new File ("dictionary.txt"));
		catch (Exception e)
			System.out.println("Error opening the file " + "dictionary.txt");
	while (inStream.hasNextLine())	
		String line = inStream.nextLine();
	final int WORDS_LENGTH = 15000;
	String [] words = new String [WORDS_LENGTH];
	for (int i = 0; i < WORDS_LENGTH; i++)
		words[i] = inStream.nextLine();
	int j = pickrandom(15000);

	public static int pickrandom(int count)
	        Random generator = new Random();
	        return generator.nextInt(count);



Have you looked into the String Builder or String Buffer classes? That was the first thing that popped into my head when thinking of how to do it. It has add and replace methods that may come in handy.

This article has been dead for over six months. Start a new discussion instead.