Hangman Game

Objective of this project

In this assignment, we needed to create a Hangman game that allowed people to guess a random word from a predetermined array of words or play against each other. These game modes were named Random and PvP. We also needed to create visuals so that players could see the man being “drawn” if they guessed wrong. In the game, players get 8 guesses and if they make a wrong one, it is decreased by one. The picture included shows the end result if someone wins. I used BlueJ to code this project.

What I Learned

From this assignment, I learned to get comfortable with ArrayLists and Java in general. A big thing this project taught me is coding style. I made many mistakes when coding this so making sure that there were comments for later reference was very helpful. I also learned how important it was to give proper names to variables and functions. I think I did a decent job because I can still read and understand everything after more than a year of not touching it.

Improvements

This game could definitely be improved upon. One improvement would be to fix the fact that my game does not recognize when there are multiples of the same letter in the word. For example, ‘apple’ has two p’s and my game can only fill in one. This is a huge problem because if you chose the PvP mode and player 1 inputted ‘buzzkill’, the code would only be able to record ‘BUZ?KIL?’ and you would have to purposely lose in order to exit the console. Another improvement I would make is to make it look like an actual game. For example, I would want to have a home screen, be able to show the letters you guessed incorrectly, have the image of the man update as you played, etc.

Source code to be made available soon.