Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: Download and extract ICE02.zip into your Exercises folder in your CS22A folder. Note : Please keep the work that you create for this exercise,

image text in transcribed

image text in transcribed

Instructions:

Download and extract ICE02.zip into your Exercises folder in your CS22A folder. Note: Please keep the work that you create for this exercise, in case you have a question about your grades for the ICEs at the end of the quarter. Work with your neighbors, type your own code, and each person should save their own, individual copy.

Notice that the index.html file has a script tag in the header for loading jQuery, a div with its id='content', and a script tag that loads main.js just before the ending body tag.

In main.js in the main function (that will be run when the window is fully loaded) create an object constructor named Computer that has three properties named speed, hdspace, and ram.

Create an instance of a Computer object and name it workComputer. Send the string values of 3.4GHz for the speed parameter, 500GB for the hdspace parameter, and 4GB for the ram parameter.

Create an instance of a Computer object and name it homeComputer. Send the string values of 4GHz for the speed parameter, 1TB for the hdspace parameter, and 16GB for the ram parameter.

Create an instance of a Computer object and name it laptop. Send the string values of 2.93GHz for the speed parameter, 250GB for the hdspace parameter, and 8GB for the ram parameter.

Create a function named getPrice that will calculate the price of a computer. The base price of a computer is 500 and should be assigned to a variable named thePrice. If the speed property of an object is equal to 4GHz, add 300 to the value of thePrice; otherwise, add 100 to thePrice. If the hdspace property of an object is 1TB, add 150 to the value of the_price; otherwise, add 80 to thePrice. If the ram property of an object is 16GB, add 200 to the value of thePrice; otherwise, add 100 to thePrice. End the function with a return statement that returns the value of the variable thePrice.

Add a call to the getPrice() function (created in step 7) to the Computer object constructor's prototype property and give the method the name price.

The provided code will create a computers object literal which will be used to easily output to the page the features and call price() for each computer object to the web page using jQuery's $("#content").append( );

Save all the JavaScript and HTML files and test in your FirefoxDeveloperEdition browser (Links to an external site.)Links to an external site.. You should have a list of features and the price for each computer written on the screen.

index.html index.html x !DOCTYPE html A 2 Q2 % ICE02: Objects

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago