C++

Light y.

asked • 08/05/22

Online Shopping Cart


Build the ItemToPurchase class with the following specifications:

  1. Default constructor
  2. Public class functions (mutators & accessors)
  3. setName() & name()
  4. setPrice() & price()
  5. setQuantity() & quantity()
  6. Private data members
  7. string _name - Initialized in default constructor to "none"
  8. int _price - Initialized in default constructor to 0
  9. int _quantity - Initialized in default constructor to 0


(Step 2) Extend the ItemToPurchase class per the following specifications:

  1. Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0).
  2. Public member functions
  3. setDescription() mutator & description() accessor
  4. printItemCost() - Outputs the item name followed by the quantity, price, and subtotal
  5. printItemDescription() - Outputs the item name and description
  6. Private data members
  7. string _description - Initialized in default constructor to "none"

Ex. of printItemCost() output:

Bottled Water 10 @ $1 = $10


Ex. of printItemDescription() output:

Bottled Water: Deer Park, 12 oz.



1 Expert Answer

By:

Bradley L. answered • 10/14/22

Tutor
New to Wyzant

System Engineer specializing in C/C++

Bradley L.

Unfortunately, I kept getting an error when I was trying to paste the code. Hopefully, you get all of the answers you need from the video. If you still need help, don't hesitate to contact me. Cheers!
Report

10/14/22

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.