Results 1 to 7 of 7
Like Tree2Likes
  • 2 Post By jim829

Thread: Beginner in Java Programming

  1. #1
    Mohammed_20 is offline Member
    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Smile Beginner in Java Programming

    Hello everybody ;

    I'm new in Java Programming and i want help to Learn the Language from you , i started the Learn from 2 weeks and i complete the basic tutorial
    but i need from you what the next step in the Learn , Can you provide me the idea of ​​a small program.


    Best Regards
    Mohammed

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,876
    Rep Power
    5

    Default Re: Beginner in Java Programming

    Sure: create a game of hangman. pure text only, no need to draw anything. It needs to have the following requirements:

    - the player is allowed to make 10 wrong guesses before he/she loses
    - the game does not run just once; if the player wins or loses, the game asks if he/she wants to go again and the user enters 'y' or 'n'
    - the game keeps track of how many times you lost and won and tells you the score every time you win or lose
    - the game loads a list of words from a text file (through Google you can find existing text files that you can use)
    - the game picks a word at random for each new round
    - the game is NOT allowed to use the same word twice in a row
    - While playing the game, the following output may be created (pay no attention to the coloring):

    Java Code:
    Word: _____
    Guess: a     <--- user input character 'a' and presses enter
    Correct!
    
    Word: __a__
    Guess: k
    Wrong! You have 9 guesses left
    
    Word: __a__
    Guess: 5
    Error: please input only characters
    
    Word: __a__
    Guess: a
    Error: you already guessed 'a'
    
    Word: __a__
    Guess: b
    Correct!
    
    Word: b_a__
    Guess: l
    Correct!
    
    Word: bla__
    Guess:
    
    ...
    (user guesses 'n' and finally 'd')
    ...
    
    Correct!
    The word was 'bland', you found it with 9 guesses left! You won 1 times and lost 0 times.
    Do you want to play another game? y  <---- user chooses 'y' or 'n'
    
    Word: _______
    Guess:
    
    etc.
    That should get you familiar with basic application flow, looping, getting and validating input, working with files, randomization and working with collections of data.
    Last edited by gimbal2; 11-27-2013 at 10:47 AM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    CTucker1327 is offline Member
    Join Date
    Nov 2013
    Posts
    6
    Rep Power
    0

    Default Re: Beginner in Java Programming

    Quote Originally Posted by gimbal2 View Post
    Sure: create a game of hangman. pure text only, no need to draw anything. It needs to have the following requirements:

    - the player is allowed to make 10 wrong guesses before he/she loses
    - the game does not run just once; if the player wins or loses, the game asks if he/she wants to go again and the user enters 'y' or 'n'
    - the game keeps track of how many times you lost and won and tells you the score every time you win or lose
    - the game loads a list of words from a text file (through Google you can find existing text files that you can use)
    - the game picks a word at random for each new round
    - the game is NOT allowed to use the same word twice in a row
    - While playing the game, the following output may be created (pay no attention to the coloring):

    Java Code:
    Word: _____
    Guess: a     <--- user input character 'a' and presses enter
    Correct!
    
    Word: __a__
    Guess: k
    Wrong! You have 9 guesses left
    
    Word: __a__
    Guess: 5
    Error: please input only characters
    
    Word: __a__
    Guess: a
    Error: you already guessed 'a'
    
    Word: __a__
    Guess: b
    Correct!
    
    Word: b_a__
    Guess: l
    Correct!
    
    Word: bla__
    Guess:
    
    ...
    (user guesses 'n' and finally 'd')
    ...
    
    Correct!
    The word was 'bland', you found it with 9 guesses left! You won 1 times and lost 0 times.
    Do you want to play another game? y  <---- user chooses 'y' or 'n'
    
    Word: _______
    Guess:
    
    etc.
    That should get you familiar with basic application flow, looping, getting and validating input, working with files, randomization and working with collections of data.
    Very nice recommendation, will get the user familiar with do-while loops. However, even after programming for almost ten years I notice this may be a little much for someone just starting out, maybe because I'm over thinking it or enjoy using the most efficient ways, but to do this correctly, wouldn't you be using a 2D Char[] array(Assuming you'd want multiple words)? Jumping straight into that after the basics seems to be a little, odd. Then again, I guess you could always just use the String.replace()
    method.

    EDIT: Didn't read thoroughly. I see now you'd have him using a BufferedReader.
    Last edited by CTucker1327; 11-27-2013 at 11:00 PM.

  4. #4
    Mohammed_20 is offline Member
    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Default Re: Beginner in Java Programming

    thanks for your replay and I will work it to create the hangman game

  5. #5
    CTucker1327 is offline Member
    Join Date
    Nov 2013
    Posts
    6
    Rep Power
    0

    Default Re: Beginner in Java Programming

    Quote Originally Posted by Mohammed_20 View Post
    thanks for your replay and I will work it to create the hangman game
    If you get stuck feel free to PM me.

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,510
    Rep Power
    5

    Default Re: Beginner in Java Programming

    Quote Originally Posted by CTucker1327 View Post
    If you get stuck feel free to PM me.
    I know you're trying to be helpful but please don't do that or encourage others to do that. Any help should be provided on this forum so others may benefit.

    Regards,
    Jim
    Norm and JosAH like this.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,876
    Rep Power
    5

    Default Re: Beginner in Java Programming

    @CTucker1327: programming is an iterative process; so is learning it. The application does not have to be perfect and complete in one go; you do it one step at a time. I can imagine that the first version has one word that is hard-coded into it and that you add support for multiple words and loading them from a file later on. The novices I've trained had no problems with it, but it required plenty of head crunching and reading, certainly. Nothing wrong with that.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Looking for a teacher for beginner Java programming
    By dazaga in forum Jobs Offered
    Replies: 4
    Last Post: 06-06-2013, 10:17 PM
  2. Replies: 1
    Last Post: 04-20-2013, 09:16 PM
  3. Replies: 1
    Last Post: 04-20-2013, 09:15 PM
  4. Need Help : student Java programming Beginner
    By wali in forum New To Java
    Replies: 13
    Last Post: 12-28-2011, 06:59 PM
  5. "Java Programming for the Absolute Beginner"
    By finalstrike777 in forum New To Java
    Replies: 2
    Last Post: 07-12-2011, 12:41 PM

Posting Permissions

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