BIT 116 - Scripting
Assignment 3

Due: February 6

Using Objects and Object Methods


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):

Use these constructor functions to create objects that represent each product for sale. Each object should represent only one item of the corresponding type - for example, you will need separate Television objects for each type of television. You will have to create fictitious information for the products on your page.

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.

Restrictions and Requirements:

What to hand in:

  1. Your A3_Products.html file.  You are not provided with a starting HTML template - you will have to make your own.
    Make sure to place the program title, A3.0, into the <title> tag in the <head> of your document for each assignment. Follow it with a “ : ” and your full name. Example: <title>A3.0: Ian Bansenauer </title>
    This is a required part of each submission!
  2. The separate .JS file that contains your JavaScript code.  As long as there's just one extra file it will be clear that you want me to grade, so you can name it whatever you want.

How To Hand In Your Homework:

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.