Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By DeNiS_M

Thread: Code check

  1. #1
    JustinP is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default 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
    Attached Files Attached Files

  2. #2
    DeNiS_M is offline Member
    Join Date
    Sep 2011
    Location
    Athens Greece
    Posts
    29
    Rep Power
    0

    Default 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! :)
    Fubarable likes this.

  3. #3
    JustinP is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default 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

  4. #4
    javaPower is offline Member
    Join Date
    Jun 2010
    Posts
    9
    Rep Power
    0

    Default Re: Code check

    Quote Originally Posted by DeNiS_M View Post
    You program appears to be running fine.
    what's about this: runGame.studentDetails()? There is no method studentDetails() in the class Hangman.

  5. #5
    JustinP is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Re: Code check

    Ah, sorry my fault there. studentDetails is a method that is called at the start of the program to display my details.

    I forgot to remove it.

Similar Threads

  1. can someone check my code plz
    By aizen92 in forum New To Java
    Replies: 20
    Last Post: 02-21-2011, 02:19 AM
  2. Code to check if a piece of code is legal.
    By vahshir in forum New To Java
    Replies: 3
    Last Post: 08-30-2010, 05:21 AM
  3. can somebody check my code
    By raven in forum New To Java
    Replies: 2
    Last Post: 08-29-2010, 09:55 PM
  4. can anyone check my code?
    By Harmesh Goyal in forum New To Java
    Replies: 8
    Last Post: 06-29-2010, 06:43 AM
  5. Can someone check my code
    By joz_12345 in forum Java 2D
    Replies: 7
    Last Post: 02-18-2008, 03:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •