#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

//PERSON CLASS
class Person
{
	protected:
		string name;
	public:
		Person (string _name) { name = _name;}
		string getName() const{ return name;}
};

//MANUFACTURE CLASS
class Manufacture
{
    protected :
        string manuName;
        string manuAdd;
        string manuCont;
    public :
        Manufacture(string _manuName, string _manuAdd, string _manuCont)
        {
            manuName = _manuName;
            manuAdd = _manuAdd;
            manuCont = _manuCont;
        }
        string getManufactureName()const{ return manuName;}
        string getManufactureAdd() const{ return manuAdd; }
        string getManufactureCon() const{  return manuCont;}
};

//PRODUCT CLASS
class Product
{
protected:
    string id, name;
    int quantity;
    float price;

public:
	Manufacture manuObj; //use for composition. When product created, Manufacture details will be created as well.
    Product(): manuObj("","","")
    { //This is the default constructor
        id = "";
        name = "";
        quantity = 0;
        price = 0.0;
    }
    Product(string _id, string _name, int _quantity, float _price, 
            string _manuName, string _manuAdd, string _manuCont): manuObj(_manuName, _manuAdd, _manuCont) 
    {
        id = _id;
        name = _name;
        quantity = _quantity;
        price = _price;
    }
    string getName()const { return name; }
    string getId()const { return id;   }
    float getPrice() const { return price;}
    int getQuantity()const {return quantity;}

    void setName(string _name) { name = _name; }
    void setPrice(float _price) {price = _price;}
    void setQuantity(int _quantity){ quantity = _quantity;}

    float operator * (const int &right){ //This is overload operator for Customer class to calculate total buy price = product * quantity
        float total = getPrice() * right;
        return total;
    }

    //These are the Polymorphism funtions
    //This is used to separate Wet product and Dry product, they will be inserted into _WetList or _DryList
    virtual void separateProductBasedCategories(vector<Product*>& _product, vector<Product*>& _WetList, vector<Product*>& _DryList, int productIndex){ 
        cout<<"This is class Product";}
    //This is used to create new instance/constructor based on their type Wet product or Dry product, they will be inserted into _WetList or _DryList.
    virtual void createChildInstance(vector<Product*>_product, vector<Product*>&_customerCart, int _quantity, float & _wetTotalPrice, float & _dryTotalPrice, int index){
        "this is class Product";
    }

    //This function is used to print the data based on _productListToPrint. _productListToPrint can be Wet list or Dry list based on what is the passed array as _productListToPrint when function called.
    void printList(vector<Product*>& _productListToPrint, int productIndex, string userType ){
            cout
                <<setw(5)<<left<<_productListToPrint[productIndex]->getId()
                <<setw(20)<<left<<_productListToPrint[productIndex]->getName()
                <<setw(8)<<left<<fixed<<setprecision(2)<<_productListToPrint[productIndex]->getPrice()
                <<setw(12)<<left<<_productListToPrint[productIndex]->getQuantity();
                if(userType == "Manager"){ //if usertType == Manager, Then information of Manufacture will be printed. It will not be printed for Customer.
            cout<<setw(25)<<left<<_productListToPrint[productIndex]->manuObj.getManufactureName()
                <<setw(35)<<left<<_productListToPrint[productIndex]->manuObj.getManufactureAdd()
                <<setw(12)<<left<<_productListToPrint[productIndex]->manuObj.getManufactureCon();
                }
                cout<<endl;
    }

    void print(vector<Product*>& _product, string userType){// This function is used to print the product List
        vector<Product*> _WetList;
        vector<Product*> _DryList;

        for(int i = 0; i < _product.size(); i++){ 
            _product[i]->separateProductBasedCategories(_product, _WetList, _DryList, i); //call separateProductBasedCategories function.
        }

        cout<<endl<<"\t\t\t ========== Wet Product List =========="<<endl;
        cout
        <<setw(5)<<left<<"CODE"
        <<setw(20)<<left<<"NAME"
        <<setw(8)<<left<<"PRICE"
        <<setw(12)<<left<<"QUANTITY";

        if(userType == "Manager"){
            cout<<setw(25)<<left<<"MANUFACTURER NAME"
                <<setw(35)<<left<<"MANUFACTURER ADDRESS"
                <<setw(12)<<left<<"MANUFACTURER CONTACT";
        }
        cout<<endl;

        for(int i = 0; i < _WetList.size(); i++){        
             _WetList[i]->printList(_WetList, i, userType); // call printList() and send WetList vector/array as _productListToPrint
        }

        cout<<endl<<endl<<"\t\t\t ========== Dry Product List =========="<<endl;
        cout
        <<setw(5)<<left<<"CODE"
        <<setw(20)<<left<<"NAME"
        <<setw(8)<<left<<"PRICE"
        <<setw(12)<<left<<"QUANTITY";
        if(userType == "Manager"){
        cout<<setw(25)<<left<<"MANUFACTURER NAME"
            <<setw(35)<<left<<"MANUFACTURER ADDRESS"
            <<setw(12)<<left<<"MANUFACTURER CONTACT";
        }
        cout<<endl;

        for(int i = 0; i < _DryList.size(); i++){        
             _DryList[i]->printList(_DryList, i, userType); // call printList() and send DryList vector/array as _productListToPrint
        }
        cout<<endl<<endl;
    }
};

class Wet : public Product
{
    public:
        Wet(string _id, string _name, int _quantity, float _price,
            string _manuName, string _manuAdd, string _manuCont )  : Product(_id,  _name,  _quantity,  _price,  _manuName,  _manuAdd,  _manuCont){}

        Wet(string _id, string _name, int _quantity, float _price) : Product( _id,  _name,  _quantity,  _price,  "",  "",  ""){} 

    void separateProductBasedCategories(vector<Product*>& _product, vector<Product*>& _WetList, vector<Product*>& _DryList, int productIndex){ //This function implemented polymorphism. The virtual function is in Product class
        _WetList.push_back(_product[productIndex]); //will insert the data of product into WetList array
    }

    //This function is called when customer want to buy wet product
    void createChildInstance(vector<Product*>_product, vector<Product*>&_customerCart, int _quantity, float & _wetTotalPrice, float & _dryTotalPrice, int pindex){
        string id = _product[pindex]->getId();
        string name = _product[pindex]->getName();
        float price = _product[pindex]->getPrice();
        _customerCart.push_back(new Wet(id, name, _quantity, price)); //will copy the product code, name and price and create new instance of Wet class. Then, it will insert the new data into Customer shopping cart array
        
        _wetTotalPrice += (*_product[pindex]* _quantity); //accumulate the total price for Wet product.
    }
};

class Dry : public Product
{
    public:
        Dry(string _id, string _name, int _quantity, float _price,
            string _manuName, string _manuAdd, string _manuCont)   : Product(_id,  _name,  _quantity,  _price,  _manuName,  _manuAdd,  _manuCont){}
        Dry(string _id, string _name, int _quantity, float _price) : Product( _id,  _name,  _quantity,  _price,  "",  "",  ""){}

    void separateProductBasedCategories(vector<Product*>& _product, vector<Product*>& _WetList, vector<Product*>& _DryList, int productIndex){ //This function implemented polymorphism. The virtual function is in Product class
                _DryList.push_back(_product[productIndex]); //will insert the data of product into DryList array
    }

    //This function is called when customer want to buy dry product
    void createChildInstance(vector<Product*>_product, vector<Product*>&_customerCart, int _quantity, float & _wetTotalPrice, float & _dryTotalPrice, int pindex){
            string id = _product[pindex]->getId();
            string name = _product[pindex]->getName();
            float price = _product[pindex]->getPrice();
            _customerCart.push_back(new Dry(id, name, _quantity, price)); //will copy the product code, name and price and create new instance of Dry class. Then, it will insert the new data into Customer shopping cart array.
            
            _dryTotalPrice += (*_product[pindex] * _quantity); //accumulate the total price for Dry product.
    }
};

class Manager:public Person
{
    protected:
        string id, pass;
    public:
        Manager(string _id,string _name, string _pass):Person(_name)
        {
            id = _id;
            pass = _pass;
        }

        string getId()   const{return id;}
        string getPass() const{return pass;}

        void edit(vector<Product*>& _product, vector<Product*>& _WetList, vector<Product*>& _DryList,  string ManagerName){
            int num;
            bool stay = true;
            editMenu:
            do{
                system("cls");
                cout << endl << "\t\t\t ====== Edit site ======";
                cout << endl << "\t\t\t 1) Add product"
                     << endl << "\t\t\t 2) Change the product"
                     << endl << "\t\t\t 3) Delete product"
                     << endl << "\t\t\t 4) Product List"
                     << endl << "\t\t\t 5) Back to main menu";
                cout << endl;
                cout<< endl  << "Hello Mr."<<ManagerName<<"! What would you like to do Today?";
                cout << "\nPlease Enter number : ";
                cin >> num;

                if(num == 1){ //if Manager enter 1, They will add new product
                        userInputAddLabel:
                        cout<<"Continue to Add new Product ? (y/n) : ";
                        char choice;
                        cin>>choice;

                        if(choice == 'y' || choice == 'Y'){
                        addProductLabel:
                            string Pid, Pname, ManuName, ManuAdd, ManuCont;
                            float Pprice;
                            int Pquantity, size = _product.size();
                            char Pcategory;
                                        cin.ignore();
                                        cout<<endl;
                                        cout <<"\t\t\t ====== New Product Registration ======"<<endl;
                                        cout<<"Enter Product Code: " ;
                                        getline(cin,Pid);
                                        cout<<"Enter Product Name: " ;
                                        getline(cin,Pname);
                                        cout<<"Enter Product Price: " ;
                                        cin>>Pprice;
                                        cout<<"Enter Product Quantity: " ;
                                        cin>>Pquantity;
                                        cout<<"Enter Product Category Wet/Dry (w,d): " ;
                                        cin>>Pcategory;
                                        cout<<"Enter The Manufacture Name: " ;
                                        cin.ignore();
                                        getline(cin,ManuName);
                                        cout<<"Enter The Manufacture Address: " ;
                                        getline(cin,ManuAdd);
                                        cout<<"Enter The Manufacture Contact Number: " ;
                                        cin>>ManuCont;

                                        if(size!=0){ //if the product array is not empty ; will check if code/name of new product is already existed
                                            for(int i = 0; i < size; i++){
                                                    if(_product[i]->getName() == Pname || _product[i]->getId() == Pid){ //if product exist
                                                        cout<<"The Code/Name of Product already existed. Please enter new Code/Name!"<<endl;
                                                        goto addProductLabel;
                                                    }
                                                    else goto newProduct; //if product not exist
                                                }
                                        }
                                        else{ //else if product array is still empty then create new product immediately
                                            newProduct:
                                            if(Pcategory == 'w' || Pcategory =='W'){
                                            _product.push_back(new Wet(Pid, Pname,  Pquantity,  Pprice,  ManuName,  ManuAdd,  ManuCont)); //create new instace of Wet product and insert into product array
                                            cout<< "\t\t\t == New Wet Product has been added ! =="<<endl<<endl;
                                            }
                                            else if(Pcategory == 'D' || Pcategory =='d'){
                                            _product.push_back(new Dry(Pid, Pname,  Pquantity,  Pprice,  ManuName,  ManuAdd,  ManuCont)); //create new instace of Dry product and insert into product array
                                            cout<< "\t\t\t == New Dry Product has been added ! =="<<endl<<endl;
                                            }
                                            else{ //if input is other than w/d or W/D
                                                cout<<"Invalid Product Category, Registration has been cancelled! Please Enter again..."<<endl<<endl;
                                                goto addProductLabel;
                                            }
                                            goto userInputAddLabel;
                                        }
                            }
                    goto editMenu; //go to Manager menu if choice != y/Y
                }
                else if(num == 2){ //if Manager enter 2, They will edit product details
                        userInputEditLabel:
                        cout<<"Continue to Edit Product ? (y/n) :";
                        char choice;
                        cin>>choice;

                        if(choice == 'y' || choice == 'Y'){
                            int size = _product.size(); //check the size of array product
                                cout<<endl<<"\t\t\t ========== Editing Product ==========="<<endl;
                                Product p;
                                p.print(_product, "Manager"); //call print function
                                cout<<endl;
                                cout<<"Enter Code/Name of Product to be edited :";
                                string Pdata;
                                cin>> Pdata;
                                
                                for(int i = 0; i < size; i++){
                                    if(_product[i]->getId() == Pdata || _product[i]->getName() == Pdata){ //if Pdata match with any product's code/name in the array of product
                                    cout<<"Product found!"<<endl;
                                    string nName, nManuName, nManuAdd, nManuCont;
                                    float nPrice;
                                    int nQuantity;
                                    cin.ignore();

                                    cout<<"Enter product's new name :"; //ask for new product's details
                                    getline(cin,nName);
                                    cout<<"Enter product's new price :";
                                    cin >> nPrice;
                                    cout<<"Enter product's new quantity :";
                                    cin >>nQuantity;

                                    _product[i]->setName(nName); //change the old product's details with the new details
                                    _product[i]->setPrice(nPrice);
                                    _product[i]->setQuantity(nQuantity);
                                    cout<<"\t\t\t ===== Product has been Updated! ======"<<endl<<endl;
                                    goto userInputEditLabel;
                                    }
                                }
                                    cout<<"Invalid Product Code/Name!"<<endl; //if no product's data match with Pdata
                                    goto userInputEditLabel;
                        }
                    goto editMenu; //go to Manager menu if choice != y/Y
                }
                else if(num == 3){ //if Manager enter 3, They will delete product 
                        userInputDeleteLabel:
                        cout<<"Continue to Delete Product ? (y/n) : ";
                        char choice;
                        cin>>choice;

                        Product p;
                        p.print(_product, "Manager"); //call print function
                        cout<<endl;

                        if(choice == 'y' || choice == 'Y'){
                            int size = _product.size(); //check the size of product array
                            cout<<endl<<"\t\t\t ========== Deleting Product =========="<<endl;
                            cout<<"insert Code/Name of Product to be deleted : "; 
                            string Pdata;
                            bool dataExist = false; //a flag to determine if Pdata match with any product's code/name
                            cin.ignore();
                            getline(cin,Pdata);
                            vector<Product*>::iterator iter; //create iterator for product vector, use to iterate each product array's data
                            for(iter=_product.begin(); iter!=_product.end();){ //will iterates through the product array
                                if((*iter)->getId() == Pdata || (*iter)->getName() == Pdata){ //if iterator pointer is match with Pdata 
                                    char confirmation;
                                    cout<<"Confirm to delete this Product? (y/n): "; // ask for confirmation to delete
                                    cin>>confirmation;
                                    if(confirmation=='y' || confirmation=='Y'){
                                        delete (*iter); //delete the iterator pointer
                                        iter = _product.erase(iter); //delete product that selected
                                        cout<<"\t\t\t ====== Product has been Deleted! ====="<<endl;
                                        dataExist = true; //will flag 
                                    }
                                    else goto userInputDeleteLabel; //if confirmation != 'y'
                                }
                                else{
                                    iter++; //increase the iterator by 1
                                }
                            }
                            if(dataExist==false){ //Product code/name does not found
                                cout<<"Code/Name of Product does not exist!"<<endl;
                            }
                            goto userInputDeleteLabel;
                        }
                    goto editMenu; //go to Manager menu if choice != y/Y
                }
                else if(num == 4){ //if Manager enter 4, They will print product list
                        userInputListLabel:
                            cout<<"Continue to See Product List? (y/n): ";
                            char choice;
                            cin>>choice;
                            if(choice == 'y' || choice == 'Y'){
                                system("cls");
                                Product p;
                                cout<<endl<<"\t\t\t ============ PRODUCT LIST ============"<<endl;
                                p.print(_product, "Manager"); //call print function
                                cout<<endl;
                                goto userInputListLabel; 
                            }
                            goto editMenu;
                }
                else if(num == 5){ //exit to main menu
                    stay = false; 
                }
                else{ 
                    cout<< "**Please Enter The Correct Value!**"<<endl;
                    goto editMenu;

                }
            }while(num < 6 && num > 0 && stay == true); 
        }
};


class Customer : public Person
{
    protected :
        string Ic;
        string noPhone;
    public :
        Customer(string Name_,string noPhone_, string Ic_):Person(Name_)
        {
            Ic = Ic_;
            noPhone = noPhone_;
        }

        string getIc(){return Ic;}

        void buyProduct(vector<Product*>_product, vector<Product*>_WetList, vector<Product*>_DryList, vector<Product*>_customerCart, string customerName){
            int num;
            bool stay = true;
            float _TotalProductPrice = 0; //will be used to store the total price of buy product
            BuyMenu:
            do{
                system("cls");
                cout << endl << "\t\t\t ====== Buy site ======";
                cout << endl << "\t\t\t 1) Buy Product"
                     << endl << "\t\t\t 2) Delete Buy Product"
                     << endl << "\t\t\t 3) Your Shopping Cart"
                     << endl << "\t\t\t 4) Back to main menu";
                cout << endl;
                cout<< endl  << "Hello, Mister/Madam "<<customerName<<"! What would you like buy?";
                cout << "\nPlease Enter number : ";
                cin >> num;

                if(num == 1){// if Customer enter 1, they will buy product 
                        CustomerBuyInputLabel:
                        cout<<"Continue to Add Product into Shopping Cart? (y/n): ";
                        char choice;
                        cin>>choice;
                    if(choice == 'y' || choice == 'Y'){
                        int size = _product.size();
                            system("cls");
                            Product p; //create product obj
                            cout<<endl<<"\t\t\t ======= AVAILABLE PRODUCT TO BUY ====="<<endl;
                            p.print(_product, "Customer"); //call print function

                            cout<<endl<<"\t\t\t === Adding Product To Shopping Cart==="<<endl;
                            cout<<"Enter Code/Name of Product to add : ";
                            string Pdata;
                            cin.ignore();
                            getline(cin,Pdata);
                            for(int i = 0; i < size; i++){
                                if(_product[i]->getId() == Pdata || _product[i]->getName() == Pdata){ //if Pdata matched with any product id/name in the array of _product 
                                    cout<<"Enter The Quantity : ";
                                    int Pquantity = 1; //default quantity is 1
                                    cin>>Pquantity;
                                    cout<<endl;
                                    float _wetTotalPrice = 0; // to store total price for wet product
                                    float _dryTotalPrice = 0; // to store total price for dry product
                                   
                                    _product[i]->createChildInstance(_product, _customerCart, Pquantity, _wetTotalPrice,  _dryTotalPrice, i); // will call virtual function of createChildInstance
                                    _TotalProductPrice += _wetTotalPrice + _dryTotalPrice; //calculate the total price of buy product
                                    
                                    int oldQuantity = _product[i]->getQuantity(); 
                                    _product[i]->setQuantity(oldQuantity - Pquantity); //They will update the product's old quantity. new quantity = old quantity - Pquantity
                                cout<<"\t\t\t === Product has been Added to Cart! =="<<endl;
                                goto CustomerBuyInputLabel;
                                }
                            }
                            cout<<"Invalid Product Code/Name!"<<endl; // invalid input
                            goto CustomerBuyInputLabel;
                    
                    }
                    goto BuyMenu;
                }
                 else if(num == 2){//if Customer enter 2, they will delete buy product 
                        CustomerInputDeleteLabel:
                        cout<<"Continue to Delete Product From Shopping Cart? (y/n): ";
                        char choice;
                        cin>>choice;
                        int size = _customerCart.size();
                        if(choice == 'y'|| choice =='Y'){
                            system("cls");
                            Product p; //create product obj
                            cout<<endl<<"\t\t\t ========== YOUR SHOPPING CART ========"<<endl;
                            p.print(_customerCart, "Customer"); //call print function. The difference between this code and the previous code is the passed array as their parameter.

                            cout<<endl<<"\t\t\t ========== Deleting Buy Product =========="<<endl;
                            cout<<"insert Code/Name of Product to be deleted : ";
                            string Pdata;
                            bool dataExist = false;
                            cin.ignore();
                            getline(cin,Pdata);
                            int productListIndex; // to get the index of product from product array.
                            for(int i = 0; i < _product.size(); i++){ productListIndex = i;} // find product's index that match with Pdata

                            vector<Product*>::iterator iter; // create iterator for Product vector 
                            for(iter=_customerCart.begin(); iter!=_customerCart.end();){ // will iterates through each product in customer's cart array.
                                if((*iter)->getId() == Pdata || (*iter)->getName() == Pdata){ //if match with any product id/name
                                    char confirmation;
                                    cout<<"Confirm to delete this Product? (y/n): ";
                                    cin>>confirmation;
                                    if(confirmation=='y' || confirmation=='Y'){
                                        float price  = (*iter)->getPrice(); 
                                        int customerQuantity = (*iter)->getQuantity();

                                        for(int i = 0; i < _product.size(); i++){
                                            if(_product[i]->getId() == Pdata || _product[i]->getName() == Pdata){
                                                int latestQuantity = _product[i]->getQuantity();
                                                _product[i]->setQuantity(latestQuantity + customerQuantity);
                                            }
                                        }

                                        delete (*iter);
                                        _TotalProductPrice -= (price * customerQuantity); // total price of buy product is updated.
                                        iter = _customerCart.erase(iter); // delete product from customer cart array
                                        cout<<"\t\t\t ====== Product has been Deleted! ====="<<endl;
                                        dataExist = true; //flag that data is existed in customer cart array
                                    }
                                    else goto CustomerInputDeleteLabel;
                                }
                                else{
                                    iter++;
                                }
                            }
                            if(dataExist==false){ // if data not existed
                                cout<<"Code/Name of Product does not exist!"<<endl;
                            }
                            goto CustomerInputDeleteLabel;
                        }
                        goto BuyMenu;
                }
                else if(num == 3){// if Customer enter 3, they will see customer shopping cart 
                        CustomerSeeCartInputLabel:
                        cout<<"Continue to See Your Shopping Cart? (y/n): ";
                        char choice;
                        cin>>choice;
                    if(choice == 'y' || choice =='Y'){
                            system("cls");
                            Product p; //create product obj
                            cout<<endl<<"\t\t\t ========== YOUR SHOPPING CART ========"<<endl;
                            p.print(_customerCart, "Customer"); //call print function. The difference between this code and the previous code is the passed array as their parameter.
                            cout<<"TOTAL PRICE IS : RM"<<fixed<<setprecision(2)<<_TotalProductPrice<<endl<<endl<<endl; // show the total price of buy products
                            goto CustomerSeeCartInputLabel;
                    }
                    goto BuyMenu;
                }
                else if(num == 4){ //exit to main menu
                    stay = false; 
                }
                else{ 
                    cout<< "**Please Enter The Correct Value!**"<<endl;
                    goto BuyMenu;

                }
            }while(num < 5 && num > 0 && stay == true); 
        }
        
};


int menu (){
    system("cls");
    cout << endl;
    cout << "\t\t\t========================" << endl
         << "\t\t\t    MARKET MAIN MENU" << endl 
         << "\t\t\t========================" << endl;
    cout << "\t\t\t||   1. Manager       ||" << endl
         << "\t\t\t||   2. Customer      ||" << endl
         << "\t\t\t||   3. Exit          ||" << endl;
    cout << endl;

    int option;
    cout << "Choose an option [1-3] => ";
    cin >> option;

    cin.ignore();

    return option;
}

int main (){
    int opt;
    string custName, custPhone, custIc;
    string manId, manPass;
    int numManager = 4;

    //create vector/array of Product pointers to store the instance of Wet/Dry classes
    //name of array/vector is _product
    std::vector<Product*> _product; 
    std::vector<Product*>_Wet; //this will be used to store instances of wet class
    std::vector<Product*>_Dry; //this will be used to store instances of dry class

    //manager array of obj pointers (id , name, password)
    Manager *listM[numManager] = {new Manager("123","waffi","123"), new Manager("1234","najwan","123"), new Manager("12345","bukhari","123"), new Manager("123456","akmal","123")};

    //create array/vector of Product to store Customer Products
    //name of array/vector is _customerCart
    std::vector<Product*> _customerCart; 


Menu:
    opt = menu();
        bool Managerexist = false;
        int Managerindex = 0;
        string Managername;
    while (opt != 3){
        switch (opt){
            case 1:
                    system("cls");
                    cout << endl << "\t\t\t===== Manager site =====" << endl;
                    cout << endl << "Enter your ID : ";
                    getline(cin, manId);
                    cout << "Enter Password : ";
                    getline(cin, manPass);

                    for(int i = 0; i < numManager; i++ ){ //check if input is exist/similar with data in manager array
                        if(listM[i]->getId() == manId  && listM[i]->getPass() == manPass){
                            Managerexist = true;
                            Managerindex = i;
                        }
                    }
                    
                    if(Managerexist == true){//if input is exist
                        Managername = listM[Managerindex]->getName();
                        listM[Managerindex]->edit(_product, _Wet, _Dry, Managername);//go to edit() in Manager
                        goto Menu;
                    }
                    else{
                        cout<<"**You Entered the wrong ID/Password. Please try again!**"<<endl;
                    }


                    break;
            
            case 2:
                    system("cls");
                    cout << endl << "\t\t\t===== Customer site ===="<<endl;
                    cout <<endl<< "Enter your IC : ";
                    getline(cin, custIc);
                    cout << "Enter your Name : ";
                    getline(cin, custName);
                    cout << "Enter your Telephone Number : ";
                    getline(cin, custPhone);

                    if(custIc != "" && custName != "" && custPhone !=""){ //will make sure that each variables is not empty
                    Customer *c1 = new Customer(custName, custPhone, custIc); //create customer pointer
                    string customerName = c1->getName(); // to get the customer name
                    c1->buyProduct(_product, _Wet, _Dry, _customerCart, customerName); //This implement aggregation. Customer's data can be deleted but product's data stay
                    delete c1;
                    }

                    break;

            default:
                     cout << "**Please Enter The Correct Value!**" << endl;
        }
        
        opt = menu();
    }

    system("pause");

    return 0;
}