A children's learning facility called "Learn 'Em" has asked you to make a simple program that will help children learn to spell. You decide that you'll make a simple "flower" game.
As you should always do, we will begin by creating a model for our application. What is the model for the flower game? Well, it is the flower game itself! So we should first find out how the flower game works. The actual flower game works as follows:
Create a Flower class to represent the model. The flower model should have at least the following:
The game should also have at least the following methods:
Create a simple main method that creates a new Flower game, guesses a few letters and shows the current state of the word and flower.
Now we will create a simple user interface called SimpleFlowerGUI which will allows us to play the game graphically. We will make use of the GridBagLayoutManager for this interface.
Before beginning, you will need some gif files to represent the flower's different states. Create 7 gif files (all the same dimensions) to represent your different flower states. Note, you can use something else other than a flower if you wish as long as it has 7 states. Here are some gif files that you may want to use: See image.
The interface should have at least the following:
Here is an example of what your interface may look like: See image.
Here are some hints on how to make this window:
Hook your user interface up to your model so that when the window opens, a new game starts with a random word. The user should be able to type a letter into the text field and then press the Guess button to make the guess. If the letter was a good one, the hidden word at the top should be updated to show the guessed letter location. If the letter guessed was wrong, the flower picture should be updated (i.e., icon changed). If the user loses the game, an appropriate message should appear somewhere on the interface (just make it part of the picture as shown above) and the Guess button and text fields should all be disabled. If the user Wins....the buttons are also all disabled, but the user should see something to indicate that he/she has won: See image.
Make sure that you follow clean GUI coding style. For example, when choosing a letter with the textfield, the user interface model should be changed so that when the guess button is pressed the letter to be used is taken from an instance variable, not directly from the text field. Hence, the event handler for the guess button should not access the textfield directly. Note that your model for your user interface may therefore consist of the Flower game as well as some other private instance variables in the user interface class.