For June 1: "The Mad Coder", 100 points

You received one too many call from customers who boot their computers with actual boots, who get white-out on the monitor trying to correct typos, who think the mouse is a foot pedal, and so on.

The boss asked you to make a simple form for users to fill out, not knowing that you now're stark raving mad and have given up all pretense about being on the same side as the users, or even the same side as your company.

You create the form, but due to the nature of your psychotic break, this is an evil form.

See the Mad Coder assignment page for the details.

For May 6: "The cover of the Rolling Stone", 100 points

The automatic hit song generator

Results:

See how different people in the class coded this homework on the results page.

Instructions:

This assigment makes use of Array objects and Math objects. Turn in your completed html file with its working JavaScript, via the "Drop box" on Blackboard.

Background

In 1974, musician Steve Goodman wrote (and David Allen Coe performed) what they have identified as the perfect country-and-western song. Here's an excerpt:

Well, I was drunk the day my Mom got outta prison.
And I went to pick her up in the rain.
But, before I could get to the station in my pickup truck
She got runned over by a damned old train.

And I'll hang around as long as you will let me
And I never minded standin' in the rain.
You don't have to call me darlin', darlin'
You never even call me by my name.

Well, so now that we all know what perfection looks like, can't you just smell the opportunity in the air?

Let's see if we can break this down into some components. Here's an example you can either use verbatim or amend as you see fit:

Well, (person1) was (condition) (unit of time) (person2) (action).
And (person1) (action) (condition).
But, before (person1) could (action) with (method of transportation)
(Person 1) got (condition) by a (condition) (condition) (method of transportation).

And I'll (action) (unit of time)
And I never (action) (condition).
You don't have to call me (nickname), (nickname)
You never even (action).

Nashville, here we come!

Assignment:

Write a JavaScript that will generate hit songs. I'm using country-and-western in my example, but if you prefer, feel free to substitute blues, jazz, rap, sappy love songs, show tunes, heavy metal, or anything else that captures your fancy.

At the bottom of the document.write() output (the song that gets printed onto the HTML page), put an HTML link back to your script so the user can generate another song by clicking on it to reload the page. For example:

< p>< a href="hitsong.html">Write another hit song< /a>< /p>

Please bear in mind that I'll be showing examples of your work in class, so don't turn in anything racist, obscene, or anything else that you wouldn't be willing to share with your mother, your 14-year-old-sister, or your classmates who you have to continue to hang out with for quite a while longer.

Hints:

  1. Store the similar items in arrays, taking care that each item in the array is worded so it'll make sense within the song structure. Here are some examples you can start with if you want to, but do add more to them.
  2. Use a property of the Array object to determine how many items are in the array.
  3. Use a random number via the Math object to assign different items from these arrays to the right places in your song. (You'll need to know the number of objects in each array to pull this off, which is why hint 2 above is important.)
  4. Special Guest Star Jason provides a big hint on creating a function to help with this assignment.
  5. Special Guest Star Kevin provides good detailed information on creating advanced functions to help with this assignment.

For April 22: "Punishment helper", 100 points

The "I will not instant-message my boyfriend/girlfriend in class" punishment helper

Results:

See how different people in the class coded this homework on the results page.

Instructions:

You should wind up with four separate html files when you're done with this assignment. Name each file as indicated below. Turn them in via the "Drop box" on Blackboard.

Background

Certainly you would never instant-message your significant other during class, but I'm sure you know a lesser someone who doesn't share your remarkable morals. As punishment for getting caught by their evil teacher, your friend has to write "I will not instant-message my boyfriend/girlfriend in class" seventy-five times.

Your friend will offer you a nice bribe if you can take care of this little problem for them so they can get back to their important flirting.

Note: this whole subject is bound to offend someone, but if you have the kind of friend who actually has a "boyfriend/girlfriend" instead of just a boyfriend or a girlfriend, that's really way more information about both you and your friend than I need to know! We'll start our coding based on the assumption that your friend is heterosexual and monogamous, and has either a single boyfriend or girlfriend--no combinations thereof.

Part one (30 points)

Create an html file named "20050422_im_assignment_part_1.html".

Write a JavaScript to help your unfortunate friend. Make it flexible enough that you can sell it to other unfortuantes who might find themselves in similar, though not identical, circumstances. The script should:

  1. Ask the person for their name
  2. Ask the person if to identify their gender
  3. Find out from the perp how many times they're supposed to write the phrase.
  4. Put the person's name at the top of the html page that this script will generate, in an <h2></h2> container.
  5. Use the gender of the individual to determine whether you're writing out "I will not instant-message my boyfriend in class" or "I will not instant-message my girlfriend in class".
  6. Output to the html page the requested content the right number of times.
  7. Use the JavaScript counter to number each iteration of the content so the mean teacher can tell that the perp has carried out the requested punishment

Part two (15 points)

Create an html file named "20050422_im_assignment_part_2.html".

Now, do another version of the same script, but instead of using Javascript to number each iteration, use the JavaScript to put the requested content inside <li></li> list container elements in an ordered list instead. Compare the output. What's different?

Part three (35 points)

Create an html file named "20050422_im_assignment_part_3.html".

We'd better be flexible in our coding, and more understanding of modern times. Make a new version of your script. Add a prompt to ask the user if they're gay or straight, and use the answer to that and the gender question to determine the "boyfriend or girlfriend" part of the output.

Part four (20 points)

Create an html file named "20050422_im_assignment_part_4.html".

We now have a nice script, but it's still limited to helping only those people who get caught instant-messaging their significant others in class. Let's branch out so we can sell this script to people who get caught doing other crimes. Make a new version of your script. Instead of having the code generate the "I will not instant-message... " phrase based on certain input (gender and sexual orientation) that's really none of our business, remove the prompts for those items. Instead, just find out from the perp for the phrase they're supposed to write, and use that information to get the right output.


For April 20: "Castle roster", 20 points

The Castle Roster loop

Instructions:

Turn in your completed html file with its working JavaScript, via the "Drop box" on Blackboard.

  1. Copy (or type) the "Castle Roster" code into Notepad (or the text editor of your choice) and save it as an HTML file named "20050420_castleroster.html".
  2. Open the file in a Web browser and make sure it works. (It should; I've removed the errors in the original.)
  3. In the code, find the comment that says "now for the ugly write-out..." and replace that line and everything that follows it with a loop. The HTML that's output by the loop should be the same as that from all the document.write statements in the example code.