Example #1
0
void MenuSupport::addProductToAllStores()
{
	Product* localProduct = getProductWithUserChoise();
	const char* const productName = localProduct->getProductName();

	StoreCountType storeCount = _shoppingStores->getStoreCount();
	for (StoreCountType i = 0; i < storeCount; i++)
	{
		Store* store = _shoppingStores->getStoreAtIndex(i);
		store->addProduct(new Product(*localProduct));
	}
	delete localProduct;
}
Example #2
0
void ShowShopCase(unsigned int shopIndex)
{
	retailNetwork[shopIndex].getShopCase(shopCase);
	printf("\nList of products from the shop case \n\n");

	for (productCounter = 0; productCounter < retailNetwork[shopIndex].getProductsAmount(); productCounter++)
	{
		Product currectProduct = shopCase[productCounter];
		currectProduct.getProductName(productName);
		printf("\nProduct%d: ", productCounter + 1);
		printf("  Name: %s\n", productName);
		printf("\t    Price: %4.2f\n", currectProduct.getProductPrice());
		printf("\t    Amount: %d\n", currectProduct.getProductAmount());
	}
}
Example #3
0
void MenuSupport::showProdutcsForStoreIndex(StoreCountType index) const
{
	if (_shoppingStores->getStoreCount() <= index)
		return;
	Store* store = _shoppingStores->getStoreAtIndex(index);
	printf("    %s:\n", store->getStoreName());

	ProductCountInStoreType productCount = store->getProductCount();
	if (0 == productCount)
		printf(kNoProductsStringMessage);
	for (ProductCountInStoreType i = 0; i < productCount; i++)
	{
		Product* product = store->getProductAtIndex(i);
		printf(kProductStringFormatMessage, i + 1, product->getProductName(), product->getProductPrice(), product->getProductAmount());
	}
}
Example #4
0
void MenuSupport::addProductToOneStore()
{
	printf(kAddProductToOneStoreByOptionMessage);
	printf(kInputSymbolMessage);
	StoreCountType storeIndex = getStoreIndexFromUserChoise();
	if (kUndefinedStoreIndex == storeIndex)
		return;

	Product* localProduct = getProductWithUserChoise();
	const char* const productName = localProduct->getProductName();
	if (0 == strcmp(productName, ""))
	{
		return;
	}

	Store* store = _shoppingStores->getStoreAtIndex(storeIndex);
	store->addProduct(localProduct);
}
Example #5
0
bool Store::addProduct(const Product & newProduct)
{
	if (newProduct.getProductName() == "" || _productCount >= kMaxCountOfProductInStore)
		return false;
	
	Product *tempShowcase = new Product[_productCount + 1];
	for (ProductCountInStoreType i = 0; i < _productCount; i++)
	{
		tempShowcase[i] = _showcase[i];
	}	
	tempShowcase[_productCount] = newProduct;
	
	delete[] _showcase;
	_showcase = tempShowcase;
	tempShowcase = NULL;
	
	_productCount++;
	return true;
}