Hangman game in c++ and java