Ejemplo n.º 1
0
Store Store::operator= (const Store & rhs)
{
	if(this == &rhs)
	{
		return *this;
	}
	delete[] _storeName;
	_storeName = NULL;
	delete[] _showcase;
	_showcase = NULL;

	if (rhs._storeName != NULL)
	{
		_storeName = new char[strlen(rhs.getStoreName()) + 1];
		strcpy(_storeName, rhs.getStoreName());
	}

	_productCount = rhs.getProductCount();
	
	_showcase = new Product[_productCount];
	for(int i = 0; i < _productCount; i++)
	{
		_showcase[i] = rhs._showcase[i];
	}
	
	return *this;
}
Ejemplo n.º 2
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());
	}
}