Welcome to Dream.In.Code
Become a Java Expert!

Join 149,604 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,895 people online right now. Registration is fast and FREE... Join Now!




Help me plzz..this is frustrating me

 
Reply to this topicStart new topic

Help me plzz..this is frustrating me

mezig101
19 Aug, 2007 - 08:41 AM
Post #1

D.I.C Head
**

Joined: 1 Aug, 2007
Posts: 54


My Contributions
Im suppose to write a code on if a player wants the instructions or not

it needs to say something like Welcome to the game of Hangman. Do you need instructions? (yes or no): and then you pick the answer if you want to see them or not but it didn't work..

I did this


CODE



String printInstructions;
    //need a way of keeping track of how far on the hangman is
    //ooooh, the length of the array list is the number of bad guesses they've made
    
    System.out.print("Instructions: ");
    printInstructions = in.next();
    
        if(printInstructions == "yes")
        {
            System.out.print("The game of hangman is a popular fill-in-the-blank word guessing game between two players. The rules for the game are as follows: ");
            System.out.println("The first player picks a word from an agreed-upon set of words, draws a blank space for each letter in the word, and draws an empty hangman's scaffold.");
            System.out.println("The first player picks a word from an agreed-upon set of words, draws a blank space for each letter in the word, and draws an empty hangman's scaffold.");
            System.out.println("The second player tries to determine what the word is by guessing letters which he thinks might be in the word.");
            System.out.println("The first player checks each guess against the letters in the selected word.");
            System.out.println("If the guess matches any letters in the actual word, the blank space for the letter is filled in for each occurrence of the guess in the word.");
            System.out.println("If the guess does not match any letters in the actual word, a piece of the stick person is added to the drawing of the hangman's scaffold.");
            System.out.println("If the second player completes the word before the drawing is completed, the second player is the winner.");
            System.out.println("However, if the hangman is completed before the word is completed, the first player is the winner.");
        }
      
        else if(printInstructions == "no")
        {
            System.out.print("Type no to quit: ");
            printInstructions = in.next();
        }
    }
    


User is offlineProfile CardPM
+Quote Post

alpha02
RE: Help Me Plzz..this Is Frustrating Me
19 Aug, 2007 - 09:25 AM
Post #2

D.I.C Addict
Group Icon

Joined: 20 May, 2006
Posts: 687


Dream Kudos: 850
My Contributions
What you've done so far is correct, except one thing:

Replace
CODE
printInstructions == "yes"


By
CODE
printInstructions.equals("yes")


This is because Strings are not stored the same way in memory. More questions? Then just reply smile.gif
User is offlineProfile CardPM
+Quote Post

mezig101
RE: Help Me Plzz..this Is Frustrating Me
19 Aug, 2007 - 09:42 AM
Post #3

D.I.C Head
**

Joined: 1 Aug, 2007
Posts: 54


My Contributions
QUOTE(alpha02 @ 19 Aug, 2007 - 10:25 AM) *

What you've done so far is correct, except one thing:

Replace
CODE
printInstructions == "yes"


By
CODE
printInstructions.equals("yes")


This is because Strings are not stored the same way in memory. More questions? Then just reply smile.gif



Thank you so muuuuch..Now i need to write the code to make a hangman game including the 7 drawings of the hangman..this'll take about 4567890 years after i figure out where to start sleep.gif
User is offlineProfile CardPM
+Quote Post

alpha02
RE: Help Me Plzz..this Is Frustrating Me
19 Aug, 2007 - 12:19 PM
Post #4

D.I.C Addict
Group Icon

Joined: 20 May, 2006
Posts: 687


Dream Kudos: 850
My Contributions
You're welcome. Any questions regarding your hangman game then just start a new topic and I will be glad yo help you. Good luck with your project!
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 11:53PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month