Here are the java files printed to PDF:
Important things to note:
- GuessingGameUI.java contains a chunk of Netbeans-generated code in the middle in a method called initComponents(). Ignore it.
- Notice that the logic of the game itself, GuessingGame.java, knows nothing about the UI. All it can do is respond to requests to:
- start the game
- receive and process a guess
- return the current status message
- say whether or not the game is over
- GuessingGame.java imports java.util.HashSet and java.util.Set. This is a mistake. They are unused. So you can ignore them.
- Notice that I have edited to the GuessingGameUI constructor to accept a handle to the GuessingGame object itself. This is so that the GuessingGameUI can send and receive messages from the GuessingGame. I have to keep a hold of this handle for the duration of the program, so I assign it to a global variable called theGame. That way, the UI can always contact theGame when it needs to (see the button code, for instance).
- In the GuessingGameUI, notice that there are only two methods apart from the constructor. They are what to do when the New Game button is pressed, and what to do when the Guess button is pressed.