890Part VCase Studies .The game s numerical (Hosting web) defaults (an

890Part VCase Studies .The game s numerical defaults (an instance of class GameParameters). .Numerical variables that track the game s state (credit, questions answered, and so on). Public functionsAs with the GameDisplayclass, let s list the functions that the Gameclass exposes to callers: .The constructor function. .Various accessor functions for member data. .updateWithAnswer()takes the player s upper and lower guesses and updates thegame s state accordingly, including both update of scores and setting up the next question to be asked. Database interactionThe actual questions and answers that the game displays are retrieved from a back-endMySQL database. There are two main types of interaction with that database: .Whenever the player moves to a new level (including the first one), the Gameobjectretrieves the IDs of all questions that may be asked at that level and scrambles theirordering. This randomized list is propagated along with the Gameobject from page topage within a particular level of the game. .Whenever a new question is actually ready to be asked, the Gameobject pops itsdatabase ID off the list constructed and then queries the question database to retrieveall the rest of the question s information (the text of the question, the correct answer, the range of possible values to present, and so on). Listing 46-4 shows game_class.php. Listing 46-4:game_class.phpIf you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

Leave a Reply