import java.io.*; // imports java package
public class WheelofFortune // the class mastermind
{
int p = 0; // the variable that the user enter his data in
int n = 0; // a counter variable
String s = ""; // user input
String[] word = {"soccer"}; // the word the user has to guess
String[] guess = new String[1]; //decleration of an array
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
public void input()
{
try
{
System.out.println(" Hello, this is hangman, please enter a letter you THINK is in the word. ");
//get the letter from user
for(int i = 0; i < 1; ++i)
{
s = br.readLine();
guess[i] = s; // user input is stored in array
i++;
}
}
catch (IOException ex)
{
ex.printStackTrace();
}
}
public void check()
{
for(int counter = 0; counter < 1 ; counter ++)
{
if((guess[counter]) .equals (word[counter]))
{
System.out.println(s); //trying to print out the parts the user guessed...
}
counter++;
}
}
}
And my runner :
public class WheelofFortunerunner
{
public static void main (String[] args)
{
WheelofFortune black = new WheelofFortune();
int r = 0;
do{
black.input(); // get input method
black.check();
}while(r < 7); // , he has 7 tries.... if he passes those tries he will loose
}
}

New Topic/Question
Reply




MultiQuote









|