Thread: Java-Hangman
View Single Post
Old 12-08-2008, 07:35 PM   #13 (permalink)
xostephie6290ox
Upright
 
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;
}
}
xostephie6290ox is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76