Extra Credit 1—Spelling Application

Part 1—Requirements


The tasks to perform to extend Lab 7 to a general application are easy.

One simplification is that the input will be capital lettes. This saves the hassle of having to convert to capitals, which isn't that hard, but it is not very instructive.
Expect to perform the following operations to create your application.

  1. To get an idea how much time is needed to solve this extra credit problem, add a comment in the head of your HTML code for the date and EXACT time to the minute shown on your computer right now. Comments are placed inside of <!-- ... --> tags.

  2. Restructure the page. Notice that the page changes organization. The command button is now above the image and has a new value. A text window must be created. And the text surrounding the two must be changed.

  3. The full alphabet of pictures must be downloaded from About.com into the exc01 folder. Consult the instructions for Lab 07 if you have forgotten the URL for the site. Don't forget to get the "extra" images for the letters J and Z.

  4. Two new variables must be declared at the start of the JavaScript section: text="" and elapsed=0.

  5. The onclick event handler for the button must be changed to perform two operations:
    • Assign the value from the text window to the variable text
    • Call the spell( ) function, as before. Remember event handlers are Javascript so semicolons(;) are required after each statement.


  6. The spell( ) function must be changed. First, it will not have any parameters. Second the processing will change to use a for loop. (Keep the last line displaying the folded hands.)

    Loops are discussed in Chapter 20 of the book, and were introduced by D. A. Clements in her lecture. The loop will iterate through the letters of the word the user typed in. The user's input will be stored in the variable text. For each letter, the show( ) function will be called.
    If the loop variable is, say, j, then the iteration starts at 0. It ends when j is less than text.length, and after each iteration, j should increase by 1, i.e. j++. The WFI is recommended
    Keep in mind that the body of a loop is enclosed in braces, { }.

At this point, nearly everything is done.

Last items to consider.

previous page   next page