void MenuSupport::removeProductFromAllStores() { printf(kRemoveProductByOptionMessage); printf(kInputSymbolMessage); if (!getUserChoise(3)) return; if (1 == _userChoise) { char* productName = inputProductName(); StoreCountType storeCount = _shoppingStores->getStoreCount(); for (StoreCountType i = 0; i < storeCount; i++) { Store* store = _shoppingStores->getStoreAtIndex(i); ProductCountInStoreType productIndex = kUndefinedProductIndex; while (kUndefinedProductIndex != (productIndex = store->getProductIndexByName(productName))) { store->removeProductAtIndex(productIndex); } } delete[] productName; } else if (2 == _userChoise) { ProductPriceType productPrice = inputProductPrice(); StoreCountType storeCount = _shoppingStores->getStoreCount(); for (StoreCountType i = 0; i < storeCount; i++) { Store* store = _shoppingStores->getStoreAtIndex(i); ProductCountInStoreType productIndex = kUndefinedProductIndex; while (kUndefinedProductIndex != (productIndex = store->getProductIndexByPrice(productPrice))) { store->removeProductAtIndex(productIndex); } } } else if (3 == _userChoise) { ProductAmountType productAmount = inputProductAmount(); StoreCountType storeCount = _shoppingStores->getStoreCount(); for (StoreCountType i = 0; i < storeCount; i++) { Store* store = _shoppingStores->getStoreAtIndex(i); ProductCountInStoreType productIndex = kUndefinedProductIndex; while (kUndefinedProductIndex != (productIndex = store->getProductIndexByAmount(productAmount))) { store->removeProductAtIndex(productIndex); } } } }