Question: c++ help this is the main.cpp file. https://codeshare.io/am6WOb ------------------------------------------------------------- /* You have to implement appropriate try catch logic for 1) Negative Price Exception 2) Item

c++ help

 c++ help this is the main.cpp file. https://codeshare.io/am6WOb ------------------------------------------------------------- /* You

have to implement appropriate try catch logic for 1) Negative Price Exception

2) Item Not In Cart Exception 3) Full Cart Exception */ #include

#include "Item.h" #include "Cart.h" #include "Produce.h" #include "Computer.h" #include "Clothing.h" using namespace

std; int main() { int ITEMLIST_SIZE = 4; int cartSize = 0,

this is the main.cpp file.

https://codeshare.io/am6WOb

-------------------------------------------------------------

/* You have to implement appropriate try catch logic for 1) Negative Price Exception 2) Item Not In Cart Exception 3) Full Cart Exception

*/

#include

#include "Item.h" #include "Cart.h" #include "Produce.h" #include "Computer.h" #include "Clothing.h"

using namespace std;

int main() {

int ITEMLIST_SIZE = 4; int cartSize = 0, i =0; double price [] = {10, 10.7, 14.5, 22.1}; // populating the inventory: itemList Item* itemList[ITEMLIST_SIZE]; Produce produce; produce.setName("apple"); produce.setPrice(price[0]); produce.setWeight(1.2); produce.setExpDate("10/20/18");

Computer comp1; comp1.setName("dell"); comp1.setPrice(price[1]); comp1.setModel("XPS13"); comp1.setYear(2017);

Clothing clothing; clothing.setName("shirt"); clothing.setPrice(price[2]); clothing.setSize("Medium"); clothing.setFabric("Cotton")

Computer comp2; comp2.setName("asus"); comp2.setPrice(price[3]); comp2.setModel("turbo"); comp2.setYear(2016);

Item* itemlist[ITEMLIST_SIZE]; itemlist[0] = &produce; itemlist[1] = &comp1; itemlist[2] = &clothing; itemlist[3] = &comp2;

/* itemQuantities[0] reflects quantity for item object contained in itemList[0] itemQuantities[1] reflects quantity for item object contained in itemList[1] itemQuantities[2] reflects quantity for item object contained in itemList[2] itemQuantities[3] reflects quantity for item object contained in itemList[3] */

int itemQuantities[] = {5, 5, 5, 7};

cartSize = 3;

cout

for(i=0;i

cout

cart.printCart();

Clothing *newItem = new Clothing(); newItem->setName(itemlist[2]->getName()); newItem->setPrice(price[2]); newItem->setSize("Medium"); newItem->setFabric("Cotton"); cout getName()

Computer *newItem1 = new Computer(); newItem1->setName(itemlist[3]->getName()); newItem1->setPrice(price[3]); newItem1->setModel("turbo"); newItem1->setYear(2016); cout getName()

cout

cout getName() removeItem(newItem); cout

Computer* changeItem = newItem1;

changeItem->setName(itemlist[1]->getName()); changeItem->setPrice(price[1]); changeItem->setModel("XPS13"); changeItem->setYear(2017); double priceIncrease = 2.99; cout getName()

changeItem->setPrice(itemlist[1]->setPrice()); double priceDecrease = 1.99; cout getName() getPrice()

return 0; }

Objective: Enhance the understanding of polymorphism and inheritance. Due: The assignment is due in BlackBoard on 11th July, 11:59 PM. Problem Design a e-commerce shopping cart. You will require classes namely Item, Computer, Produce, Clothing and Cart. All Class attributes are private while class methods are public. Your Item class should be a abstract class and contain: Attributes name -name of the Item. it is a protected class attribute *price price of the item. it is a protected class attribute. Methods setName() sets the name of Item. It is public class method. * setPrice) sets the price of Item. It is public class method. getName() retrieve name. It is public class method. * getPrice() - retrieve price. It is public class method. Overloaded operator +. Public method Overloaded operator-. Public method. Pure virtual function print(). Public method. Constructors (with parameters and default) Tip: to perform some operations on items in the cart, it may be convenient (but not required) to add to the Item class an overloaded equality operat. This may come in handy when looking for items in the cart

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!