Exercise: Hangman

Write the game Hangman as a console application:

Example program output (user input in green):

Welcome to the Hangman game!
=====================
Word to guess: ****
Guessed characters: 
Lives left: 6
Enter a character: e
Wrong guess!
=====================
Word to guess: ****
Guessed characters: e
Lives left: 5
Enter a character: a
Good guess!
=====================
Word to guess: *a*a
Guessed characters: ea
Lives left: 5
Enter a character: j
Good guess!
=====================
Word to guess: Ja*a
Guessed characters: eaj
Lives left: 5
Enter a character: v
Good guess!
Congratulations! You've guessed the word: Java
Check if the user enters only one character. If the user enters more than one character, print a message and ask for a new character:
Welcome to the Hangman game!
=====================
Word to guess: ****
Guessed characters: 
Lives left: 6
Enter a character: abcdef
Please enter a single character.
=====================
Word to guess: ****
Guessed characters: 
Lives left: 6
Enter a character: 
Tell the user if they have already guessed the character:
Welcome to the Hangman game!
=====================
Word to guess: ****
Guessed characters: 
Lives left: 6
Enter a character: j
Good guess!
=====================
Word to guess: J***
Guessed characters: j
Lives left: 6
Enter a character: J
You already guessed that character.
=====================
Word to guess: J***
Guessed characters: j
Lives left: 6
Enter a character: 

Methods

You are not allowed to use these methods of String from the Java standard library: Instead, write your own methods, for example: Using these methods from String is allowed:

Hand in instructions

  1. Make sure your program runs correctly.
  2. Hand in your program by uploading Main.java to Moodle.