Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ShoppingCart Class Create variables for ShoppingCart Class Private: _ Customer Private: _ product 1 Private: _ product 2 Private: _ product 3 Create Constructor that

ShoppingCart Class
Create variables for ShoppingCart Class
Private: _Customer
Private: _product1
Private: _product2
Private: _product3
Create Constructor that takes in a Customer as an argument
ShoppingCart(Customer cust)
Make sure that the GetCustomerId() returns the same Id as the customer that was put in the argument in the constructor.
Create Methods
GetCustomerId() : int
Returns the customer's id
GetProductById(int id) : ShoppingCartItem
Returns the product with matching id
AddProduct(Product prod) : ShoppingCartItem
Runs other add product method with quantity of 1
AddProduct(Product prod, int quantity) : ShoppingCartItem
Checks for valid quantity
Checks for product and adds quantity if found
Adds product if new
Returns the product changed or null
RemoveProduct(Product prod, int quantity) : ShoppingCartItem
Checks for valid quantity
Checks for product and removes quantity if found
Returns the product changed or null
GetTotal() : decimal
returns total of all products
GetProduct(int prodNum) : ShoppingCartItem
returns the product in the position of prodNumor null
image text in transcribed

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What is digital literacy? Why is it necessary?

Answered: 1 week ago