Heres what ive got sofar
Here is what I have so far. Please don't be rude this time, and instead help me. I am seriously stuck. The program reads in from a file containg 4 letter words : Cake, Play, Bank, Ball, Dogs, Cats, Meow, Beer, Bear, Cars, Lamp. The program needs to check the word vs the guess and keep track of the number of incorrect guesses.
import java.util.*;
import java.io.*;
public class hangman
{
public static void main(String [] args) throws IOException
{
getHeading ();
startHangman ();
}
public static void getHeading () throws IOException
{
System.out.println(“Hi folks how are you today? Hope your day is going swell!”);
System.out.println(“Today we are going to play the game of Hangman!”);
System.out.print(“You will be given 5 tries before the game is over”); System.out.print(“ and the man has been fully hanged.”); System.out.println(“Let’s get started!”);
}
public static void startHangman () throws IOException
{
int maxTries = 5;
int secretWordLen;
BufferedReader infile;
Infile = new BufferedReader (new FileReader (“HangmanList.txt”));
String wordlist = fileScan.next();
String secretWord [] = wordlist[(int)Math.floor(Math.random() * wordlist.length)];
secretWordLen = Math.min(s.length(), maxWordLen);
for (i=0; i<secretWordLen; i++)
{
secretWord[i] = s.charAt(i);
}
String Response;
System.out.println(“What is your name”);
Response = in.readLine();
Response = new name;
hangPlayer = new player(name);
System.out.println(hangPlayer);
}
}
private class player
{
private player(String name)
{
int winCount = 0;
int loseCount = 0;
System.out.print(name + (", you have won " + winCount + " and you have lost ") + loseCount);
return name;
}
}
|