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





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; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
