![]() |
|
#1
|
|||
|
|||
Any help would be appreciatedHey there guys I'm new to java OOP and im not very good at it at all. I have a uni assignment due in soon which i mostly completed but I'am stuck on this questions which ask us to make a guessword game. this is the problem
Problem 3 – The Guess-a-Word Game (15% implementation, 10% design, code, layout and comments) The guess-a-word game, as the name suggests, is a game of guessing words. You will be playing this game with the computer in charge of the game. Suppose the word you have to guess is: PROGRAMMING The computer would start by displaying the word with each letter replaced by an asterisk: *********** Number of mistakes = 0 Wrongly guessed letters = “” Letters available = “ABCDEFGHIJKLMNOPQRSTUVWXYZ” That display means that so far you have not made any mistakes and the set of wrongly guessed letters is empty. You are then asked to play a letter. Suppose you play letter “M”. The computer would display: ******MM*** Number of mistakes = 0 Wrongly guessed letters = “” Letters available = “ABCDEFGHIJKLNOPQRSTUVWXYZ” Next suppose you play letter “E” which is not one of the letters of the word. Then the computer would display: ******MM*** Number of mistakes = 1 Wrongly guessed letters = “E” Letters available = “ABCDFGHIJKLNOPQRSTUVWXYZ” And so on until you successfully guess all the letters in the word, or until you make nine mistakes. You are required to do the following: • First, design and create a class called GuessWord to represent a game. (If you freeze the game at a point in time and observe its state, then what do you see? What would constitute the state of the game? How would the game change its state?) • Second, provide a text-based interface program called GuessWordTest that will allow the user to play the game once. The text-based interface program should use the class you create in step 1. The interface will ask for a word to guess (that is entered at the keyboard), then the dialog between the user and the program is similar to that described above. And here is the coding i have done so far JAVA Code:
Then my text based interface is JAVA Code:
My defined class (GuessWord) compiles with no error, so i'am no sure wat is wrong PLEASE ANYBODY HELP THIS NOOB OUT, i appreciate anyone who even bothered read my problem Last edited by LuciWiz : 27-May-2006 at 05:59.
Reason: Please insert your Java code between [java] & [/java] tags
|
|||
|
#2
|
||||
|
||||
Re: Any help would be appreciatedJust because the program compiles fine, doesn't mean that it has no logic flaws...
So, what is the first errors that you are getting? (I already know, but this is to help you work through them [and learn!]) __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
||||
|
||||
Re: Any help would be appreciatedI'll help a bit more... you are probably getting this after the first letter guess:
Quote:
Notice inside the () is: ( <filename>.java:<linenumber> ) (your line numbers may be different) the first "at" after the exception shows that GuessWord failed during 'init' at line 7 in GuessWord.java ... and this was at a point called from GuessWordTest.java, in GuessWordTest.main, at line 16 in the file. [which happens to be in main()] If you check main at line 16, you are calling a new GuessWord() object, but it failed during initialization. This should help you resolve errors as they appear, but if not, reply back and include the stack dump(s). __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#4
|
|||
|
|||
Re: Any help would be appreciatedok ive adjusted my code, just note that i made copys of the original files and renamed the filenames and classes.
JAVA Code:
And the other.... JAVA Code:
Im still having some NullPointerException errors with hiddenWord and within the second code im having trouble with the condition in my while loop comparing an char array with a String word, and ideas how to go about this? thx again Last edited by cable_guy_67 : 27-May-2006 at 19:34.
Reason: Changed [CODE] tags to [JAVA]
|
|
#5
|
||||
|
||||
Re: Any help would be appreciatedWhat has occurred is that in lele's constructor, you created hiddenWord (be careful of using common names between classes, by the way) as a new String, but there is nothing in the String! (null)
No need to pass hiddenWord to the constructor of class lele. Move the loop that you have to fill hiddenWord with '*' to the contructor of lele just after where you create the new String for hiddenWord. After moving the loop, remove hiddenWord = new String[e] and the fill-loop from lala. Start with that and see how it goes. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! Last edited by TurboPT : 27-May-2006 at 21:15.
|
|
#6
|
|||
|
|||
Re: Any help would be appreciatedk thank you dude, i really appreciate any help
|
|
#7
|
||||
|
||||
Re: Any help would be appreciatedYou must have caught me in-between edits, see post #5.
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#8
|
|||
|
|||
Re: Any help would be appreciatedOK this is wat ive changed but im still geting errors
JAVA Code:
and.... JAVA Code:
lol this thing is killing me Last edited by cable_guy_67 : 28-May-2006 at 06:52.
Reason: Please use [JAVA] code tags for your java code
|
|
#9
|
||||
|
||||
Re: Any help would be appreciatedYou didn't get my suggestion quite right, but I meant like this:
constructor changes (after // markers)... JAVA Code:
changes to main (after // markers)... JAVA Code:
Try that and see how it goes. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#10
|
|||
|
|||
Re: Any help would be appreciatedK ive made all those adjustments but my problem still lies within initialzing the array in the constructor.. i am confused how to do it:S
|
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Noob with a question,any help would be greatly appreciated :) | yrostran | C Programming Language | 7 | 11-May-2006 02:44 |
| C++ Calculator Problem. Any help much appreciated. | SpinDizzy | C Programming Language | 13 | 12-Jul-2005 13:35 |
| probably a stupid mistake....lil help appreciated | wbsquared03 | C++ Forum | 9 | 06-Dec-2004 15:43 |
| Need help with a program if anyone can help it would be appreciated | Krc784 | C++ Forum | 1 | 03-Nov-2004 20:55 |
| Minor Problem with my program. Any help greatly appreciated. | agentxx04 | C Programming Language | 6 | 24-Oct-2004 15:04 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The