Keywords: clear search

## Welcome to the Futurama Support Site

The Futurama Support Site is the website where you can find Futurama and Futurama Vision documentation. If you have any questions about the support pages or if you want to provide us feedback please send us an e-mail.

Index Exercise 2: The Guessing Game II (Medium)

451 documents found.

# Exercise 2: The Guessing Game II (Medium)

Developer
Tutorial

Module: Editor

Version: 4.2.1 +

User: Developer

Difficulty: Medium

Introduction

In this exercise we will display a graph in our website.

Prerequisites

- The Futurama Editor must be installed.
- Futurama Runtime must be installed.
- Completing the tutorial Adding interactivity to your website first, is recommended.

## Description

This is a sequel of the The Guessing Game I (Creating formulas with Futurama). You can download the basis for this exercise (the end-result of the The Guessing Game I 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 the first part of the exercise, we've constructed the formulas needed to play the game. In this part, we will construct the WebPage with the interactivity to play the game.

## Assignment

Create a website in which you can play the game. This means: A webpage with an input field in which you can enter your guess, and an output field that states whether your guess is correct, or should be higher or lower.

Take the following steps to do so:

1. Create a WebPage object and name it ‘Start’. (This WebPage should be the StartWebPage of your document)
2. Within the WebPage, create a WebLabel and name it 'DescriptionInputBox'. In the property 'Text', enter the text: 'Choose a random number between 0 and 100'.
3. Below this description, create a TextBox. In this Textbox the user will enter his or her guess. Name it 'InputBox'.
4. The TextBox should be linked to a UserVariable. The value entered in the textbox is submitted into this UserVariable, and it should then be compared to our randomly chosen number. Therefore the Fixed Value 'InputNumber' should be used as our UserVariable. Rightclick the Fixed 'InputNumber' and choose 'Change to'. Now select the 'UserVariable'.
5. Now create a button within your website. You only have to enter the Text property, for instance with the next 'Click', or 'Submit'. The button will invoke a postback.
6. Now create another WebLabel and name this one 'Message'. In the Text property, refer to the Formula 'MessageCorrectHigherLower'.

As you'll might notice, the 'randomly' chosen number won't change each time you play the game. To achieve this, we will have to use the Unique_value property of the Rand()-formula:
1. We will use a Formula that returns the current Date and Time as our unique value. Everytime you start the webpage, off course this value will be different. This formula is a Type Date formula, so it can not be used directly, as the unique value should be a String.
Therefore, within the formula Rand(), first create another Formula, 'FormatDate'.
2. Within this formula, select the Date Formula 'Now()' in the Date section. In the Format section, enter 'hh;mm;ss'. This means the hours, minutes and seconds of the current date and time will be returned. This ensures a unique value every time the website is started.
3. Save your file, and verify that the random number is now different every time you play the game.

## Tips

• Do not forgot to refer to your WebPage in the StartWebPage property of your Document.
• When you start the WebPage you already see a message: Correct, higher or lower. We will change this in part III of this exercise.
• In this Exercise, Futurama only gives one random number and sticks with that number. We want Futurama to choose a new random number once the user has guessed the number correctly. This will also be done in part III of this exercise.