SHARE
TWEET

Untitled

a guest Dec 14th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void checkIfClientsHaveProduct(Buyer**& clientsArr, const int& clientsSize,
  2.     char* productToSearch)
  3. {
  4.     int haveIt = 0;
  5.     for (int i = 0; i < clientsSize; i++)
  6.     {
  7.         for (int j = 0; j < clientsArr[i]->getNumOfProductInShoppingCart(); j++)
  8.             if (strcmp(clientsArr[i]->getShoppingCart()[j]->getName(),
  9.                 productToSearch) == 0)
  10.                 haveIt++;
  11.  
  12.         if (haveIt)
  13.         {
  14.             cout << clientsArr[i]->getUserName() << " has " << haveIt
  15.                 << " " << productToSearch << endl << endl;
  16.  
  17.             haveIt = 0;
  18.         }
  19.     }
  20. }
  21.  
  22.  
  23. void checkIfSellersHaveProduct(Seller**& sellersArr, const int& sellersSize,
  24.     char* productToSearch)
  25. {
  26.     int haveIt = 0;
  27.     for (int i = 0; i < sellersSize; i++)
  28.     {
  29.         for (int j = 0; j < sellersArr[i]->getNumOfProductSold(); j++)
  30.             if (strcmp(sellersArr[i]->getProductSold()[j]->getName(),
  31.                 productToSearch) == 0)
  32.                 haveIt++;
  33.  
  34.         if (haveIt)
  35.         {
  36.             cout << sellersArr[i]->getUserName() << " has " << haveIt
  37.                 << " " << productToSearch << endl << endl;
  38.  
  39.             haveIt = 0;
  40.         }
  41.     }
  42. }
  43.  
  44.  
  45.  
  46. void showProductsWithSameName(Buyer**& clientsArr, const int& clientsSize
  47.     ,Seller**& sellersArr, const int& sellersSize)
  48. {
  49.     char *productToSearch = askProductName();
  50.  
  51.     cout << "Clients:\n";
  52.     checkIfClientsHaveProduct(clientsArr, clientsSize, productToSearch);
  53.    
  54.     cout << endl << "Sellers:\n";
  55.     checkIfSellersHaveProduct(sellersArr, sellersSize, productToSearch);
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top