Results 1 to 5 of 5
Thread: Code check
- 09-17-2011, 09:08 AM #1
Member
- Join Date
- Sep 2011
- Posts
- 3
- Rep Power
- 0
Code check
G'day
I'm really new to programming and using forums so please excuse any mistakes, but word me up and I'll remember for next time.
I have an assignment question that requires me to make a hangman game. I need to have a hangman class that can be used to play a simple game, then a client class that plays three games of hangman. The secret word must be passed from the client to the hangman class.
I have completed the code and it all works but I don't think the way I am calling the hangman class into the client class is correct.
I have attached the hangman class and client class. If someone with a bit of know how is willing to have a look for me it'd be appreciated. I know my coding is very basic and there are definately better ways of doing it but my main concern is following the rules of java and object-oriented programming.
Any help would be appreciated.
Cheers
Justin
- 09-17-2011, 11:24 AM #2
Member
- Join Date
- Sep 2011
- Location
- Athens Greece
- Posts
- 29
- Rep Power
- 0
Re: Code check
You program appears to be running fine.
And your code is well structured enough.
You should write a constructor for your Hangman class.
In the Hangman class rename your main method (for example Run()).There should be only one main method per application.
And you should remove the static identifiers from your methods and your properties.This will make your code more object oriented!
Feel free to tell me your opinion regarding those recommendations! :)
- 09-17-2011, 12:09 PM #3
Member
- Join Date
- Sep 2011
- Posts
- 3
- Rep Power
- 0
Re: Code check
Denis,
mate thanks very much for your help. Very much appreciated.
I'm studying externally so don't really have anyone to bounce ideas off or check my work. I regularly do something and think "hmmm that doesn't seem right" but it's not as easy as you might think to find the answer.
Prime example is using the constructor as you suggested, instead of 2 mains, which then allowed me to remove the static identifiers, because main methods should always be static, is that correct??
Thanks again for your help. Any other info or suggestions you can provide are appreciated.
Cheers
Justin
- 09-17-2011, 06:05 PM #4
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
- 09-17-2011, 11:07 PM #5
Member
- Join Date
- Sep 2011
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
can someone check my code plz
By aizen92 in forum New To JavaReplies: 20Last Post: 02-21-2011, 01:19 AM -
Code to check if a piece of code is legal.
By vahshir in forum New To JavaReplies: 3Last Post: 08-30-2010, 04:21 AM -
can somebody check my code
By raven in forum New To JavaReplies: 2Last Post: 08-29-2010, 08:55 PM -
can anyone check my code?
By Harmesh Goyal in forum New To JavaReplies: 8Last Post: 06-29-2010, 05:43 AM -
Can someone check my code
By joz_12345 in forum Java 2DReplies: 7Last Post: 02-18-2008, 02:58 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks