char hangman[];
Scanner sc = new Scanner( System.in);
Random r = new Random();
File input = new File("ComputerText.txt").useDelimiter(",");
Scanner sc = new Scanner(input);
String words;
I want to read in a set of words from a .txt file and have the program select a random word to use in the hangman game.
The below code is for when we get the .txt file to be read inside the code. We want to use three different .txt files with a different category each and have the user pick which category they want their word from.
//while(decision==1){word=computerWord;}
if ( decision == 1)
{
word=computerWord;
}
else if ( decision == 2)
{
word = countryWord;
}
else if (decision == 3)
{
word = fruitWord;
}
else
{
System.out.println("error, try again");
}
Aucun commentaire:
Enregistrer un commentaire