assign6_s_f88/ProductInventory.cpp
/*****************************************************************************
 addProduct: Input validation
 Product p, passes Product as pa
 returns: bool, false if duplicate, or not "invalid", else true
 ****************************************************************************/
Input validation
Product p, passes Product as pa
returns: bool, false if duplicate, or not "invalid", else true
Input validation Product p passes Product as pa returns : bool false if duplicate or not " invalid " else true
bool ProductInventory::addProduct(Product pa)
{
    ProductNode *newNode;       
    newNode = new ProductNode;
    newNode->data = pa;
    newNode->next = NULL;
    if (productList==NULL)
    {
        productList = newNode;
    }
    else {
        ProductNode *p = productList;
        while (p->next != NULL)
        {
            if(pa.isEqual(p->data))
            {
                return false;
            }
            p = p->next;
        }
        p->next = newNode;
    }
    return true;
}
bool ProductInventory :: addProduct ( Product pa ) { ProductNode * newNode ; newNode = new ProductNode ; newNode -> data = pa ; newNode -> next = NULL ; if ( productList == NULL ) { productList = newNode ; } else { ProductNode * p = productList ; while ( p -> next != NULL ) { if ( pa . isEqual ( p -> data ) ) { return false ; } p = p -> next ; } p -> next = newNode ; } return true ; }
addProduct: Input validation
Product p, passes Product as pa
returns: bool, false if duplicate, or not "invalid", else true
addProduct : Input validation Product p passes Product as pa returns : bool false if duplicate or not " invalid " else true
//pointer to newNode
 // now p points to the last node
