• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need help with a hangman project

 
Jesse Schlicklin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my code. I've been stressing out and have tons of questions/concerns. If somebody would be kind enough to help what through my code with me and could point me in the right direction for each class that would be great.

If we could start with the static boolean printCurrStatus(String strToGuess, String userInputs) class that would be great.

Thank you!

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are all the methods static?
 
Jesse Schlicklin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Why are all the methods static?


The professor wants it done both in static and non-static.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea what that means.
 
Jesse Schlicklin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:I have no idea what that means.


I'm sorry he wants us to rewrite the Hangman.java program into Hangman2.java (after Hangman.java is finished), and the Hangman2.java is suppose to have all static keywords removed except for the static on the method main.


But I'm still stuck on the Hangman.java
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, it is correct that only main should be static.

What specific problems are you having?
 
Jesse Schlicklin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:OK, it is correct that only main should be static.

What specific problems are you having?


My printCurrStatus and playGame methods are not working correctly. My output is coming out "Enter a Letter", and when I enter one it's asking me to enter another one instead of printing out

Current Status for userInputs: a

_ _ _ _ _ _

Enter a Letter


I believe it has to do with my printCurrStatus not properly printing the information out.
 
Jesse Schlicklin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I went ahead a rewritten my code last night, but if somebody could help me figure out whats wrong with my output that would be wonderful!

My output is bolded and it's not letting ------, Letters Guessed:, and Enter next letter take its own line without being all smashed together. Also my Letters Gussed (found in printCurrStatus) is printing out the word that needs to be found. Also my -------, isn't keeping track of all the letters that were found. In my output when 'e' is found the 'a' dissapears; this also is found in (printCurrStatus).

Any help would be greatly appreciated.

Enter next letter
a
---a--- Letters Guessed: giraffeEnter next letter
d
------- Letters Guessed: giraffeEnter next letter
b
------- Letters Guessed: giraffeEnter next letter
e
------e Letters Guessed: giraffeEnter next letter
g
g Letters Guessed: giraffeEnter next letter


 
Jesse Schlicklin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed the line seperate problem and the other two problems remain.

output:

Enter next letter:
a
_ _ _ _ _ _
Current user input : simple
Enter next letter:
d
_ _ _ _ _ _
Current user input : simple
Enter next letter:


code:

 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesse Schlicklin, please BeForthrightWhenCrossPostingToOtherSites <= click the link
http://www.java-forums.org/new-java/70852-hangman-problem.html
 
Jesse Schlicklin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:Jesse Schlicklin, please BeForthrightWhenCrossPostingToOtherSites <= click the link
http://www.java-forums.org/new-java/70852-hangman-problem.html


I'm sorry about that I'll make sure it's done in future posts.
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesse Schlicklin wrote:I fixed the line seperate problem and the other two problems remain.

You know what? I reckon you should StopCoding.

First off, your program doesn't seem to be following the rules of Hangman (at least as I remember the game), because you don't appear to be storing either ALL the guesses that the user has tried or the current state of the game.

If I remember right, if the hidden word is "cubbyhole" and I enter:
1st guess: a
2nd guess: b
3rd guess: c
I should see
c _ b b _ _ _ _ _
and one stick of the hanging frame (for the bad guess), but you only ever seem to compare the word with a single letter.

My advice: Turn off your computer and write down ALL the rules of the game exactly, and in English.
Then write out the steps needed to follow those rules (also in English) - in particular, how to display the letters that have been correctly guessed so far (and I warn you, there's more than one way to do it).

HIH

Winston
 
Jesse Schlicklin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Jesse Schlicklin wrote:I fixed the line seperate problem and the other two problems remain.

You know what? I reckon you should StopCoding.

First off, your program doesn't seem to be following the rules of Hangman (at least as I remember the game), because you don't appear to be storing either ALL the guesses that the user has tried or the current state of the game.

If I remember right, if the hidden word is "cubbyhole" and I enter:
1st guess: a
2nd guess: b
3rd guess: c
I should see
c _ b b _ _ _ _ _
and one stick of the hanging frame (for the bad guess), but you only ever seem to compare the word with a single letter.

My advice: Turn off your computer and write down ALL the rules of the game exactly, and in English.
Then write out the steps needed to follow those rules (also in English) - in particular, how to display the letters that have been correctly guessed so far (and I warn you, there's more than one way to do it).

HIH

Winston


My professor doesn't actually want the 'stick' part showing because it's a intro class (his words); I would love to take your advice and most certainly will in later projects, but I'm in a time crunch on this one.
 
Chip Furstenau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing I noticed is your call to the printCurrStatus() method has your arguments reversed. In the call you have userInputs first, and in your method signature you have strToGuess first. I'm fairly new to this myself, but I think that's part of your problem.
 
Jesse Schlicklin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chip Furstenau wrote:One thing I noticed is your call to the printCurrStatus() method has your arguments reversed. In the call you have userInputs first, and in your method signature you have strToGuess first. I'm fairly new to this myself, but I think that's part of your problem.


That may actually really help thanks! I've got to look at my printCurrStatus again.
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesse Schlicklin wrote:I would love to take your advice and most certainly will in later projects, but I'm in a time crunch on this one...

I presume you've heard the story of the Tortoise and the Hare? - Well, good programmers are tortoises.

It may not seem like it right now, but the time you spend backing off and thinking about the problem will almost certainly be less than all the faffing around you're likely to have to do to get your square peg of a program to fit into its round hole.

Chip's observation is well spotted, but I don't think that simply correcting that is going to solve your problems (for all the reasons I mentioned previously).

You can't code your way out of a jam.

Winston

PS: If you post more code, please DontWriteLongLines (←click). Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic