Project: Hangman

Problem Description:

Write a program which plays Hangman with TV series names. Hangman is a game where a user given a fix number of tries to find a secret word. Your program must choose a random word from the word list below and must allow the user to guess maximum 10 characters from the alphabet before printing gameover. If user can guess the whole word before 10 characters user wins.

Wordlist : Merlin, Dexter, The Closer, House, Friends, Survivor, Simpsons

  1. To check whether a String is equal to another String use equals method in String class:

String s1 = “Hello”;

String s2 = “World”;

boolean r= s1.equals(s2);

  1. To retrieve the ith character of a String use charAt method which returns the character of a String at a given index i.

public char charAt(int index)

  1. Your program must check to make sure user enters characters one by one.

  2. After each guess program diplays current word which shows correctly guessed characters and hides not guessed charachters. For example:

t _ ( You have 5 guesses left)

You can also display the state of the hangman graphically . At the end of the game whether user wins or fails, program asks user whether he/she wants to play the game again. If user presses ‘y’ or ‘Y’, game starts again, else program ends.

12 years ago*

Comment has been collapsed.

help you or write the entire thing for you

12 years ago
Permalink

Comment has been collapsed.

really can you write for me ? :)

ı am try to write but ı can't do :(

12 years ago
Permalink

Comment has been collapsed.

...

12 years ago
Permalink

Comment has been collapsed.

Seems like it's homework...Shouldn't you be doing it?:3

12 years ago
Permalink

Comment has been collapsed.

it a project . and if I don't do that ,who is give me project, he is dropping me in this course. and ı don't want to take thise course anymore :(

12 years ago
Permalink

Comment has been collapsed.

Better get cracking then

12 years ago
Permalink

Comment has been collapsed.

while i do know do basic programming i am not familiar with java the best i can do is provide a source code type guide for you, would that help?

12 years ago
Permalink

Comment has been collapsed.

why not it may be help for me :)

12 years ago
Permalink

Comment has been collapsed.

bad boy.

12 years ago
Permalink

Comment has been collapsed.

^^

12 years ago
Permalink

Comment has been collapsed.

Do your own homework. Unless you want code in COBOL then I will gladly give it to you.

12 years ago
Permalink

Comment has been collapsed.

^ what he said, its not really hard man, its just some simple conditioning you need to setup but if you still need help ask away

12 years ago
Permalink

Comment has been collapsed.

ı am try but ı dont do it...

12 years ago
Permalink

Comment has been collapsed.

this project must be write java :(

12 years ago
Permalink

Comment has been collapsed.

import java.util.Scanner;

public class Hangman {
public static void main(String[] args) {

int attempts = 10;
int wordLength;
boolean solved;
Scanner userInput = new Scanner(System.in);

System.out.println("OK Guessing Player ... turn around, while your friend enters the word to guess!\n");
System.out.println("Other Player ? Enter your word (letters only, no repeated letters and not case sensitive):");

String secretWord = userInput.next();
for(int i = 1; i <= 20; i++)
    System.out.print("\n");

    Scanner userLetter = new Scanner(System.in);
    String letter;

    System.out.print("Word to date: ");
    for (int i = 0; i < secretWord.length(); i++)
    {
        System.out.print("*");
    }

    while (attempts <= 10 && attempts > 0)
    {
        System.out.println("\nAttempts left: " + attempts);
        System.out.print("Enter letter: ");

        attempts--;
    }

    System.out.println("\n---------------------------");
    System.out.println("Sorry you didn't find the mystery word!");
    System.out.println("It was \"" + secretWord + "\"");

}

12 years ago
Permalink

Comment has been collapsed.

netBeans is not accept this codes combination

12 years ago
Permalink

Comment has been collapsed.

Use eclipse netbeans sucks balls

12 years ago
Permalink

Comment has been collapsed.

okey ı am try eclipse

12 years ago
Permalink

Comment has been collapsed.

Let's not start a flame. He can use notepad for something as small as this.
I'm not saying one is better than the other, I'm using them both.

12 years ago
Permalink

Comment has been collapsed.

honestly doesn't matter what he uses, could be his compiler is not set up correctly.

12 years ago
Permalink

Comment has been collapsed.

Did you find this on Google?

12 years ago
Permalink

Comment has been collapsed.

ı find on google and then ı changed and developed

12 years ago
Permalink

Comment has been collapsed.

You should really try to do it yourself. Start small, baby steps.
Create a main method. Try to figure out how you would read input. How would you use the words given to you.

We can help you, but we won't give you the solution out right.

12 years ago
Permalink

Comment has been collapsed.

okey ı am try and than ı will write here , thanks for help

12 years ago
Permalink

Comment has been collapsed.

pretty sure he did the english is a bit to good and no offense I doubt it is your native language.
And also this code will not satisfy your requirements for the project.
You need to think this through first before coding.

12 years ago
Permalink

Comment has been collapsed.

ı am turk but university we study in English education

12 years ago
Permalink

Comment has been collapsed.

I can help you think this through but you need to do your own coding, mostly since I really know only C++, python and some older languages only, just started to teach myself java and I kind of hate how clunky it feels. Before I start have you been keeping up with the class or have you fallen behind and you still have no idea how to write a hello world program

12 years ago
Permalink

Comment has been collapsed.

public clas ComradeStallion{

public static void main(String[]args){

System.out.println("hello world");

}

}

come down ... just want to help...

12 years ago
Permalink

Comment has been collapsed.

when googling for an answer:
Try to find a solution, not a another problem. The code you posted is from here: http://stackoverflow.com/questions/4988143/simple-java-hangman-assignment and obviously the OP of this code did not get his program to work properly.

When you google "public class Hangman { public static void main(String[] args)" you find lots of examples (again, make sure it's a solution, not a problem).

Also: do your homework alone (it#s for your own good, how else are you supposed to understand what the code does?).
Since displaying the hangman graphically is optional, this is a rather trivial task, good luck ;)

12 years ago
Permalink

Comment has been collapsed.

thanks for help :)

12 years ago
Permalink

Comment has been collapsed.

Closed 12 years ago by CsM.