Due: February 6
CHANGED on Jan 30, 2007: If you want to, you can work with a SINGLE PARTNER for this homework assignment. You may also do the assignment on your own, if you wish. If you work with a partner, then you will both get the same grade for this assignment, and for the revision to the assignment (if you two choose to submit a revision).
You are going to create a web page for an electronics store that displays information about the following products that they have for sale - televisions, computers, and speakers. The store carries 4 types of each product. (For example, the store carries 4 types of Television: maybe a Zenith, a Toshiba, a Sony, and a RadioShack). Your task is to create a page that effectively displays the information about each product according to the guidelines below.
Create an object constructor function for each type of product - one for televisions, one for computers, and one for speakers. The specific fields for each object are listed below (you can add more if you choose):
Create an object method for each type of object that will be used to return a single string that is generated from all of the fields in that object, including any formatting that is needed to make the product look good. Use the prototype property of the constructor function to assign this method to the toString method. Here is some sample code that does this:
function TelevisionToString() {...}
function Television(...) {...}
Television.prototype.toString = TelevisionToString;
In this way, you can generate the html for each product by accessing its corresponding object directly, without having to repeat code.
You must store all the products in an array. In order to obtain the string
for the web page, you will need to iterate through the array, and call toString
on each object in the array.
You are free to decide the format of
the page.
document.write() statement. As in assignment 2, you will
need to use the string + operator to create a single string that
represents the entire page.alert() boxes when you encounter problems with your
script. You can alert the string of html that your script is generating
to see whether or not it is being generated correctly. Use newlines
("\n") in the string to space it out so that it is readable
inside the alert box.This will be handed in via the Vault system. If you need help, we can cover this again in class, on the date that this assignment is due.