Answered step by step
Verified Expert Solution
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: product
Private: product
Private: product
Create Constructor that takes in a Customer as an argument
ShoppingCartCustomer 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
GetProductByIdint id : ShoppingCartItem
Returns the product with matching id
AddProductProduct prod : ShoppingCartItem
Runs other add product method with quantity of
AddProductProduct 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
RemoveProductProduct 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
GetProductint prodNum : ShoppingCartItem
returns the product in the position of prodNumor null
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started