31.03.2014 Views

project plan example javascript

project plan example javascript

project plan example javascript

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

My Magic Month<br />

Project Description<br />

This program will guess the user’s favorite month of the year. The user will choose the month<br />

they love best and translate the name into its numeric value (i.e. January=1 or 01; December=12). Once<br />

the user has the month and initiates the program, the program will first guess any number between 1 and<br />

12. After this guess, the user will respond with “h” for high, “l” for low or “c” for correct to guide the<br />

program’s guesses. After the program guesses the right number corresponding to the user’s favorite<br />

month, it will display how many guesses it took to reach the correct answer, and allow the user to play<br />

again (with their second favorite month…).<br />

Pseudocode – 1 st level<br />

Variables<br />

Guess = current guess (1st guess random)<br />

Upper = upper limit (Start set at 12)<br />

Lower = lower limit (Start set at 1)<br />

Turns = how many turns it takes the computer to guess<br />

Response = user’s hints (“h” or “l” or “c”)<br />

Explain game to user<br />

Choose your favorite month. Convert to its numeric value. The program will then attempt to<br />

guess your favorite month, but you need to guide it by typing “h” for month numbers that are too high,<br />

“l” for those that are too low and “c” when the computer guesses correctly. Press start to initiate the<br />

program’s guessing.<br />

Generate a random number between 1 and 12<br />

Make guess (Message to user: Here’s my guess. Tell me if it’s high, low or correct.)<br />

As long as user does not input “c”,<br />

Increment turn counter<br />

If user inputs “h”,<br />

Set the upper limit of the program to the last guess<br />

Keep lower limit same<br />

Make new guess<br />

If user inputs “l”<br />

Set the lower limit of the program to the last guess<br />

Keep upper limit same<br />

Make new guess<br />

If user inputs “c”<br />

Stop guessing<br />

Tell how many turns it took<br />

Allow to user to play the game again by pressing reload<br />

Pseudocode – 2 nd level<br />

Variables<br />

upper = 12<br />

lower = 1<br />

Print out game instructions:


Choose your favorite month. Convert to its numeric value: i.e. January = 1, December = 12. I'll try to<br />

guess your favorite month, but you'll have to help me. Enter h if my guess is too high, l if it's too low,<br />

and c if I'm right on. Ready to play?<br />

Guess = Generates a random guess between 1-12 (don’t put in loop)<br />

response = Print out guess. Enter h if my guess is too high, l if my guess is too low, or c if my guess is<br />

right on.<br />

while (response not correct)<br />

add 1 to the turn counter each repetition<br />

if (response is high)<br />

upper = guess;<br />

guess = Math.floor((upper + lower)/2);<br />

response = Print out guess. Enter h if my guess is too high, l if my guess is too low, or c if<br />

my guess is right on.<br />

else (response is low)<br />

lower = guess;<br />

guess = Math.floor((upper + lower)/2);<br />

response = Print out guess. Enter h if my guess is too high, l if my guess is too<br />

low, or c if my guess is right on.<br />

if (response is correct)<br />

Print I knew it! Number of turns.<br />

Visual Design<br />

Include, link to, or describe what your <strong>project</strong> will look like visually.<br />

Testing<br />

To test the program, I will begin by building it step-by-step in TextWrangler. After each new<br />

section, I’ll save and refresh the page in the Browser to see if it works. This process will allow me to test<br />

as I build, and therefore spot any mistakes right away. Once I’ve written the whole program, I’ll test it<br />

with a few different months. I’ll make sure to count the number of guesses it takes to make sure the<br />

program is counting this right.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!