Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer part A and B Objective: Class composition In an online shopping web application, the user views several items to buy. Each item can

Please answer part A and B image text in transcribed
image text in transcribed
Objective: Class composition In an online shopping web application, the user views several items to buy. Each item can be added to the shopping cart. When the user check-out, all the items in the shopping cart are listed and the total price is computed. A. Design and Implement a class which can hold up to 20 Items. Use a normal array as a container for the items. The ShoppingCart class must have the following attributes and methods: Class attributes: All items must be declared private a. itemList defined as 1 dimensional array composed of the previously user defined Item data type (class) and holds a maximum size of 20 items.(refer to lab 4) numltems an integer represents the total number of items currently in the shopping cart defaulted to zero. b. Class constructors Only a default constructor should be defined to create an empty shopping cart. When this constructor is called, it should initialize the array itemList and set the numltems to zero ShoppingCart Class methods: a. Class Methods a. addltem(ltem anltem): this method take anlTem as input and add it to the itemList array. Each time an item is added, the numitem must be incremented. This methods returns nothing (void). removeltem(String itemname): this method takes an item name and remove it from the shopping cart itemList. If the item was removed correctly, this methods return true Boolean value. If the item is not in the itemList, it should return false Boolean value. b. c. checkout0: this method will print out a list of all items in the shopping cart and count and print the total items price. Note: you have to apply good programming style and documentation in developing and maintaining your codes. B. Use the previously implemented Class to test by doing the following 1. 2. 3. 4. Define a ShoppingCart Add the items to the shopping cart Remove one item from the shopping cart Checkout and display the total of the items in the cart. Note: you have to apply good programming style and documentation in developing and maintaining your codes

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

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago