Version: 4.2.1 +
In this exercise we will finish our guessing game.
- The Futurama Editor must be installed.
- Futurama Runtime must be installed.
- Completing the tutorial Working with Actions in Futurama first, is recommended.
This is a sequel of the The Guessing Game II (Creating formulas with Futurama). You can download the basis for this exercise (the end-result of the The Guessing Game II exercise) by clicking here.
Guess the number is a game we're creating in Futurama. In this game you have to guess a number that is chosen randomly (by Futurama). This number lies between 0 and 100. When the user enters a number, the game will say whether the guess is correct, or should be higher, or lower.
In this last part of the exercise we further improve our latest version of the game. We enable that once the number is guessed, a new number is chosen. And we make sure that the hint only appears when a number is entered, not by default.
Implement the above named feautres to the game.
Take the following steps to do so:
- We will use the ClearCache object for this.
Add the ClearCache object at the bottom of the page. In the TargetObject, refer to the 'RandomSelected 0-100' formula.
- The ClearCache should only be executed when the answer is correct. Therefore, in the Condition property of the ClearCacheObject, refer to the Formula 'AnswerCorrect'.
- Select the WebLabel in which the hint is displayed. Set the property 'Visible' of this WebLabel to 'False'. Verify in your browser that the Message is not displayed now.
- Within the Button object, create an Action object, named 'Set Message Visible'.
- In the 'TargetControl' property, refer to the WebLabel in which the hint is displayed.
- Within the Action object, create a Fixed Type Boolean, named 'Visible'. Set the value of the Fixed to True. This means, when the button is clicked, the visibility property of the Hint message will be set to 'True'.
- Save your file and verify in your browser that the message is now shown after you've clicked the button.
- In the previous Exercise we filled in the Unique value of the Random Formula by using the Date Formula Now(). Because it's result is constantly changing, we get a new random number each time the website is started again. The Formula is only executed when its value is asked and has not been calculated yet.
- The function ClearCache resets the target object ‘RandomSelected 0-100’. It empties the value that is cached. Therefore, when continuing the game, the Formula will be referred to again, and the new 'Now()'-result will be used as the unique value for the Random Formula.
- You can use the VersionNumber property of the Document to enable version management.
You can download our solution for this assignment by clicking the image at the right. (Futurama 188.8.131.52)
Please note that you can very well have a different solution that is just as good as ours.
- (Easy:) By using WebPanels, let the Hint appear below the button instead of to the right of it.
- (Medium:) Add a button to the webpage by which you can reset the chosen number manually.