Question: Can you please just correct this code. When i run this code on visual studio it gives me error. So please correct that errors. Thanks

Can you please just correct this code. When i run this code on visual studio it gives me error. So please correct that errors. Thanks  

 

#include

#include

#include

#include

#include

using namespace std;

class Customer{

                public:

                                string FirstName, LastName;

                                enum ProductCategory{Grocery, Electronics, Beverages, CleaningSupplies, Miscellaneous};

                                Customer(){

                                }

                                Customer(string f, string l){

                                                FirstName = f;

                                                LastName = l;

                                }

                                string ToString(){

                                                string s;

                                                s = FirstName+" "+LastName;

                                }

};

class Order:public Customer{

                public:

                int static ORDER_NUM;

                int OrderID, Quantities;

                double OrderCost;

                ProductCategory Category;

                Order(){

                }

                Order (string fName, string lName) : Customer(fName, lName){

                                Quantities = 1;

                                Category = Miscellaneous;

                                OrderID = ORDER_NUM++;

                                CalculateOrderCost();

                }

                Order (string fName, string lName, int quantities) : Customer(fName, lName){

                                Quantities = quantities;

                                Category = Miscellaneous;

                                OrderID = ORDER_NUM++;

                                CalculateOrderCost();

                }

                Order (string fName, string lName, ProductCategory Category) : Customer(fName, lName){

                                Quantities = 1;

                                this->Category = Category;

                                OrderID = ORDER_NUM++;

                                CalculateOrderCost();

                }

                Order (string fName, string lName, ProductCategory Category, int quantities) : Customer(fName, lName){

                                Quantities = quantities;

                                this->Category = Category;

                                OrderID = ORDER_NUM++;

                                CalculateOrderCost();

                }

                void CalculateOrderCost(){

                                OrderCost = 2 * ((Category == Miscellaneous) ? 20 : ((Category == Electronics) ? 15 : (Category == Beverages) ? 10 : (Category == CleaningSupplies) ? 5 : 1));

                                OrderCost += (0.13 * OrderCost);

                }

                string ToString(){

                                string s, s2;

                                stringstream ss, ss1, ss2;

                                if (Category == 0)

                                                s2 = "Grocery";

                                else{

                                                if (Category == 1)

                                                                s2 = "Electronics";

                                                else{

                                                                if (Category == 2)

                                                                                s2 = "Beverages";

                                                                else{

                                                                                if (Category == 3)

                                                                                                s2 = "CleaningSupplies";

                                                                                else

                                                                                                s2 = "Miscellaneous";

                                                                }

                                                }

                                }

                                s = "Order ID:- ";

                                ss2<

                                s.append(ss2.str());

                                s.append("\nFirst Name:- ");

                                s.append(FirstName);

                                s.append("\nLast Name:- ");

                                s.append(LastName);

                                s.append("\nCategory:- ");

                                s.append(s2);

                                s.append("\nQuantities:- ");

                                ss<

                                s.append(ss.str());

                                s.append("\nTotal Order Cost:- ");

                                ss1<

                                s.append(ss1.str());

                                return s;

                }

};

int Order::ORDER_NUM = 170;

class IOperations: public Order{

                public:

                                virtual void PurchaseProduct(string productName, string manufacturer, int quantity) = 0;

                                virtual void PurchaseProduct(string firstName, string lastName, ProductCategory type) = 0;

                                virtual void PurchaseProduct(string firstName, string lastName, ProductCategory type, int quantity) = 0;

                                //virtual void ReturnProduct(int orderID);

};

class PurchaseManager : public IOperations{

                public:

                                list OrderList;

                                PurchaseManager(){

                                                //OrderList = new list;

                                }

                                void PurchaseProduct(string firstName, string lastName, int quantity){

                                                OrderList.push_back(Order(firstName, lastName, quantity));

                                }

                                void PurchaseProduct(string firstName, string lastName, ProductCategory type){

                                                OrderList.push_back(Order(firstName, lastName, type));

                                }

                                void PurchaseProduct(string firstName, string lastName, ProductCategory type, int quantity){

                                                OrderList.push_back(Order(firstName, lastName, type, quantity));

                                }

                                void CancelTickets(int orderID){

                                                list :: iterator it;

                                                for(it = OrderList.begin(); it != OrderList.end(); it++)

                                                                if (it->OrderID == orderID)

                                                                                OrderList.erase(it);

                                }

                                void ShowAll(){

                                                list :: iterator it;

                                                for(it = OrderList.begin(); it != OrderList.end(); it++)

                                                                cout<ToString()<

                                }

                                void ShowAll(string firstName){

                                                list :: iterator it;

                                                for(it = OrderList.begin(); it != OrderList.end(); it++){

                                                                string s = it->FirstName;

                                                                char *ch = &s[0];

                                                                if (strcmp(ch, &firstName[0]) == 0)

                                                                                cout<ToString()<

                                                }

                                }

};

int main(){

                PurchaseManager *p = new PurchaseManager();

                p->PurchaseProduct("A", "B", p->Electronics, 2);

                p->PurchaseProduct("C", "D", 2);

                p->PurchaseProduct("E", "F", p->Electronics);

                cout<<"All data\n";

                p->ShowAll();

                p->CancelTickets(171);

                cout<<"All data after deletion of one data\n";

                p->ShowAll();

                cout<<"Data of E\n";

                p->ShowAll("E");

                return 0;

}

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 Computer Network Questions!