Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Javascript-- This is going to run at the command prompt, does not need to work in a web browser Create a script called retail_store.js. In

Javascript-- This is going to run at the command prompt, does not need to work in a web browser

Create a script called retail_store.js. In this script code the following:

A. Class and Constructor Creation

RetailItem Class

Create a constructor function or ES6 class for a RetailItem object. The RetailItem object should store the following data in attributes: item description, units in inventory, and price.

CashRegister Class

Create a constructor function or ES6 class for a CashRegister object that will be used with the RetailItem class. The CashRegister object should be able to internally keep an array of RetailItem objects.

B. Methods to add

CashRegister Class

The class should have the following methods:

o A method named purchaseItem that accepts a RetailItem object as an argument. Each time the purchaseItem method is called, the RetailItem object that is passed as an argument should be added to the list of retailItems the CashRegister contains.

o A method named getTotal that returns the total price of all the RetailItem objects stored in the CashRegister objects internal list.

o A method named showItems that writes the information about each retail item stored in the cash register to the console.

o A method named clear that should clear CashRegister objects internal list.

C. Test Program

After you have created the classes. Create three RetailItem objects and store the following data in them:

Description Units In Inventory Price
Item #1 Polo Jacket 12 59.95
Item #2 Roberto Cavalli Jeans 40 34.95
Item #3 Sean Jean Shirt 20 24.95

Store all three RetailItem objects in an array named inventory

Next, create a CashRegister object.

Add all the items to the CashRegister using the purchaseItem method. Display the total using the CashRegister getTotal method. Display all the items using the CashRegister showItems method.

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

What is a statement of work (SOW)? What purpose does it serve?

Answered: 1 week ago