Purchase Solution

A simple game written in javascript using random numbers

Not what you're looking for?

Ask Custom Question

Please see the attached file.

Design and implement a Web page named esp.html that allows the user to conduct an ESP test. Your page should look something like the one in Figure 11.10. The rectangle containing a question mark represents the back of a card that is associated with a particular shape. After contemplating which shape appears on the front of the card, the user clicks the button corresponding tot he shape he or she believes is on the card (here, four possibilities are assumed). After each guess, the question mark should be replaced by a randomly selected shape, and an alert box should notify the user as to whether the guess was correct. Statistics concerning the number and percentage of correct guesses should be maintained in text boxes. After the statistics have been updated and the alert box has been closed, the page should restore the question-mark image, enabling the user to enter another guess.

Attachments
Purchase this Solution

Solution Summary

This solution creates a simple game written in javascript. It demonstrates how to use functions and random numbers. It also shows how to link javascript to a button.

Solution Preview

The Javascript for this solution is show in the code below. Comments in the code indicate what is happening with each group of statements.

function esp(choice)
{
// First we pick a random id that corresponds to an image
var randomId = Math.floor(Math.random()*4+1);

// Display the image. An id of 1 = square, 2 = triangle, etc.
if (randomId == 1) {
displayImage("square");
}
if (randomId == 2) {
displayImage("triangle");
}
if (randomId == 3) {
displayImage("circle");
}
if (randomId == 4) {
displayImage("star");
}

...

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic Networking Questions

This quiz consists of some basic networking questions.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.