Пример #1
0
/*!
  Tries to buy a product with \a iapId.
*/
void IAPurchase::buyProduct(QString iapId)
{
    if (m_buyProductRequestId) {
        // Purchase ongoing, reject this request
        emit busy();
        return;
    }

    Product *product = productFromCacheByProductId(iapId);

    if (!product) {
        // Product does not exist!
        emit productDoesNotExists(iapId);
        return;
    }

    // Buy the product
    int requestId = m_iapClient->purchaseProduct(iapId, IAPClient::ForcedAutomaticRestoration);
    product->setReqId(requestId);

    if (requestId > 0) {
        // Request ok
        m_buyProductRequestId = requestId;
    }
    else {
        // Error
        m_buyProductRequestId = 0;
        emit productPurchaseError();
    }
}
Пример #2
0
void NewSale::makeNewSale() {
	bool endOfSale = false;
	pos->newSale();
	while (!endOfSale) {
		cout << "Enter product code: ";
		int productCode;
		cin >> productCode;
		Product* product = pos->getProductByCode(productCode);
		if (product == 0) {
			cout << "Unknown product." << endl;
			continue;
		}
		cout << "Product description: " << product->getDescription() << endl;
		cout << "Enter quantity: ";
		double quantity;
		cin >> quantity;
		try {
			pos->enterSaleItem(quantity, product);
			cout << "Sale total: " << pos->getSaleTotal() << endl;
		} catch (ValidationError& err) {
			cout << err.getMessage() << endl;
		}
		cout << "0: End sale\n1: Continue adding items";
		int command;
		cin >> command;
		if (command == 0) {
			pos->endSale();
			endOfSale = true;
		}
	}

}
Пример #3
0
void ProductMapping::checkProductInfo(const Product & product)
{
    // check whether the product itself is disabled for new reports,
    // which usually means that product/application is unmaintained.
    m_bugzillaProductDisabled = !product.isActive();

    // check whether the product on bugzilla contains the expected component
    if (! product.components().contains(m_bugzillaComponent)) {
        m_bugzillaComponent = QLatin1String("general");
    }

    // find the appropriate version to use on bugzilla
    const QString version = m_crashedAppPtr->version();
    const QStringList& allVersions = product.allVersions();

    if (allVersions.contains(version)) {
        //The version the crash application provided is a valid bugzilla version: use it !
        m_bugzillaVersionString = version;
    } else if (version.endsWith(QLatin1String(".00"))) {
        //check if there is a version on bugzilla with just ".0"
        const QString shorterVersion = version.left(version.size() - 1);
        if (allVersions.contains(shorterVersion)) {
            m_bugzillaVersionString = shorterVersion;
        }
    }

    // check whether that verions is disabled for new reports, which
    // usually means that version is outdated and not supported anymore.
    const QStringList& inactiveVersions = product.inactiveVersions();
    m_bugzillaVersionDisabled = inactiveVersions.contains(m_bugzillaVersionString);

}
Пример #4
0
int main(int argc , char *argv [])
{
  Factory *factoryA = new FactoryA ();
  Product *productA = factoryA->CreateProduct();
  productA->Show();
 
  Factory *factoryB = new FactoryB ();
  Product *productB = factoryB->CreateProduct();
  productB->Show();
 
  if (factoryA != NULL)
  {
    delete factoryA;
    factoryA = NULL;
  }
 
  if (productA != NULL)
  {
    delete productA;
    productA = NULL;
  }
 
  if (factoryB != NULL)
  {
    delete factoryB;
    factoryB = NULL;
  }
 
  if (productB != NULL)
  {
    delete productB;
    productB = NULL;
  }
  return 0;
}
Пример #5
0
void process_products(istream& fs)
{  vector<Product*> products;
   bool more = true;
   while (more)
   {  Product* p = new Product;
      try
      {  if (p->read(fs)) products.push_back(p);
         else more = false;
      }   
      catch(runtime_error& r)  // runtime_error& r)
      {  cout << "1. " << r.what() << endl;
         for (int i = 0; i < products.size(); i++)
                                delete products[i];
         throw;                       
         return;                                                                     
      }                     
    }     
   /* processing products */       
   
   cout << "Print:" << endl;
   for (int i = 0; i < products.size(); i++)
   {  products[i]->print();
      delete products[i];
   }      
}
Пример #6
0
int main()
{
    Shopper shopper(100);
    int n;
    cout << "Enter number of products: ";
    cin >> n;
    cin.get();

    for(int i = 0; i < n; i++)
    {
        Product p;
        p.read();
        shopper.addProduct(p);
        cout << endl;
    }

    double maxWeight;
    cout << "Enter max weight: ";
    cin >> maxWeight;

    while(shopper.totalWeight() > maxWeight)
    {
        char* nameOfHeaviestProduct = shopper.nameOfHeaviestProduct();
        shopper.removeProduct(nameOfHeaviestProduct);
    }

    shopper.print();
    shopper.buyProducts();

    cout << "Now your cash is " << shopper.getCash() << "\n";

    return 0;
}
Пример #7
0
/**
 * Determine the model number, cost, and description of the product 
 *  that is associated with a barcode. If the product is on sale, this 
 *  check will return the sale price. 
 *
 * @return SUCCESS on success, else -1
 */
static int do_check(void) {
	Product *p = NULL;
	char bc[BARCODE_SZ] = {0};
	float sale_price = 0.0;
	unsigned int d_len = 0;

	// recv barcode
	RECV(STDIN, bc, BARCODE_SZ);

	// find product in inventory with matching bar code
	p = get_product_by_barcode(bc);

	// if not found, return -1
	if (NULL == p) return -1;

	// if found, send model number, cost, and description
	SEND(STDOUT, (char *)&p->model_num, sizeof(unsigned int));

	sale_price = p->sfn(p->model_num, p->cost);
	SEND(STDOUT, (char *)&sale_price, sizeof(float));

	d_len = strlen(p->desc, '\0');
	if (0 < d_len)
		SEND(STDOUT, p->desc, d_len);
	// terminate the description string
	SEND(STDOUT, DESC_TERM, 1);

	return SUCCESS;
}
Пример #8
0
Product ProductController::FindProductUsingRFIDTag(char* RFIDTag, bool queryShopInventory)
{
	//Log.Info("FindProductUsingRFIDTag Begin"CR);

	vector<Product> temp;
	if(queryShopInventory)
		temp = shopVector;
	else
		temp = tempVector;

	for(int i=0; i<temp.size(); i++)
	{
		char* rfidTag = temp[i].GetRFIDTag();
		if(strcmp(rfidTag, RFIDTag) == 0)	
		{
			//Log.Info("Match found."CR);			
			return temp[i];			
		}
	}
	
	//Log.Info("FindProductUsingRFIDTag End"CR);

	// A quick work-around as you cannot return a null object only a null pointer.
	Product product; product.SetRFIDTag("-1"); 	product.SetDescription("-1"); 	product.SetPrice(1);

	return product;
}
Пример #9
0
bool operator<(const Product &prod1, const Product &prod2){
    string prod1Name = prod1.getName();
    string prod2Name = prod2.getName();
    if(prod1Name < prod2Name)
        return true;
    return false;
}
Пример #10
0
void ProductOrder::print() {
    cout << "Name: " << prod.getName()
         << "\nPrice: "
         << prod.getPrice()
         << "\nQuantity: " << quantity
         << "\nTotal Amount: "
         << getTotal() << "\n";
}
Пример #11
0
void AddProductToAShop(StringType productName, int shopIndex)
{
	Product ourProduct;
	ourProduct.setProductName(productName);
	ourProduct.setProductPrice((double)rand() / 100);
	ourProduct.setProductAmount(rand() % kMaxixumAmountOfProducts + 1);
	if (!retailNetwork[shopIndex].addProduct(ourProduct))
		printf("\nToo many products in shop %d!\n\n", shopCounter + 1);
}
Пример #12
0
void Equipment::show()
{
	Product *p = head;
	while (p)
	{
		p->print();
		p = p->next;
	}

}
Пример #13
0
BasketItem::BasketItem(unsigned int _quantity, const Product& p, unsigned int _discount100)
{
    virt = false;
    
    pid = p.getPID();
    name = p.getName();
    price100 = p.getPrice100();
    discount100 = _discount100;
    quantity = _quantity;
}
int main(int argc, char* argv[])
{
	Product* pro;//接收产品的指针
	//将一个具体的构建者付给指挥者
	Director* d = new Director(new ConcreteBuilder());
	pro=d->Construct();//调用产生产品
	pro->fun();
	printf("Hello World!\n");
	return 0;
}
void ProductsSearchResponse::parseNormalResponse() {
  parseError();
  if (responseParser->hasName("products")) {
  QList<Parser *> listParser = responseParser->getListObjectParser("products");
  Parser *parser;
  foreach (parser, listParser) {
    Product tmp;
    tmp.setParser(parser);
    tmp.parseResponse();
    products.append(tmp);
  }
Пример #16
0
int main()
{
    Builder * builder = new ConcreteBuilder();
    Director director;
    director.setBuilder(builder);
    Product *pd = director.constuct();
    pd->show();

    delete builder;
    delete pd;
    return 0;
}
Пример #17
0
/*!
  Returns a product from the cache by \a productId or NULL if not found.
*/
Product *IAPurchase::productFromCacheByProductId(QString productId)
{
    for (int i = 0; i < m_productCache.count(); i++) {
        Product *p = (Product*)m_productCache[i];

        if (p->id() == productId) {
            return p;
        }
    }

    return 0;
}
      // Calcular valor total dos produtos do carrinho
   float getTotalPrice()
        {
          
           Product* sweeper = firstProduct;
           float sum=0;

           while(sweeper->getNextProduct() != NULL)
                  sum += sweeper->getPrice();

          return sum;           

        } 
Пример #19
0
/*!
  Returns a product from the cache by \a requestId or NULL if not found.
*/
Product *IAPurchase::productFromCacheByRequestId(int requestId)
{
    for (int i = 0; i < m_productCache.count(); i++) {
        Product *p = (Product*)m_productCache[i];

        if (p->reqId() == requestId) {
            return p;
        }
    }

    return 0;
}
Пример #20
0
bool ProductController::AddProduct(char* RFIDTag, char* Description, int Price)
{ 
  Product product;
  product.SetRFIDTag(RFIDTag);
  product.SetDescription(Description);
  product.SetPrice(Price);

  it = tempVector.insert(it, product);

  //Log.Info("List contains %d items."CR, tempVector.size());

  return true;
}
Пример #21
0
int main()
{
	StandardCreator<ProductA> creatorA;
	Product* product = creatorA.createProduct();
	std::cout << "Product: " << product->getName() << std::endl;
	delete product;

	StandardCreator<ProductB> creatorB;
	product = creatorB.createProduct();
	std::cout << "Product: " << product->getName() << std::endl;
	delete product;
	return 0;
}
Пример #22
0
void Product::CloneScalars( OperandList& scalarList ) const
{
	for( const OperandList::Node* node = operandList.Head(); node; node = node->Next() )
	{
		const ScaledSymbol* scaledSymbol = dynamic_cast< ScaledSymbol* >( node->data );
		if( scaledSymbol && scaledSymbol->scalar )
			scalarList.InsertAfter()->data = scaledSymbol->scalar->Clone();

		Product* product = dynamic_cast< Product* >( node->data );
		if( product )
			product->CloneScalars( scalarList );
	}
}
Пример #23
0
InvoiceLine InvoiceLine::fromProduct(const Product &p)
{
    InvoiceLine line;

    line.setName(p.getName());
    line.setDescription(p.getDescription());
    line.setPrice(p.getPrice());
    line.setQte(1);
    line.setOffPercentage(0);
    line.setBaseProductId(p.getId());

    return line;
}
Пример #24
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;
}
Пример #25
0
int main()
{  
   Product best;
   Product secondBest;

   bool more = true;
   while (more)
   {  
      Product next;
      next.read();
      if (next.is_better_than(best)) {
	secondBest = best;
	best = next;
      }
      else {
	if(next.is_better_than(secondBest)) {
	  secondBest = next;
	}
      }


      cout << "More data? (y/n) ";
      string answer;
      getline(cin, answer);
      if (answer != "y") more = false;
   }

   cout << "The best value is ";
   best.print();
   cout << "The second best value is ";
   secondBest.print();

   return 0;
}
Пример #26
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());
	}
}
Пример #27
0
int main()
{
  std::cout << "Factory Method GoF Kata" << std::endl;

  // we're programming to interfaces here; we know nothing about
  // ConcreteProduct!
  Application* application = new ConcreteApplication();
  Product* product = application->createProduct();
  product->Use();

  delete application;
  delete product;

  return 0;
}
Пример #28
0
/* ИЗПОЛЗВАНЕ НА КЛАСА */
int main()
{  Product best;       /* дефиниране на обект от класа */
   bool more = true;
   while (more)
   {  Product next;
      next.read();    /* извикване на член-функция на класа */
      if (next.is_better_than(best)) best = next;
      cout << "More data? (y/n) ";
      string answer;
      getline(cin, answer);
      if (answer != "y") more = false;
   }
   cout << "The best bang for the buck is ";
   best.print();        /* извикване на член-функция на класа */
   return 0;
}
Пример #29
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());
	}
}
Пример #30
0
void DisplayCart::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);

	DDX_Control(pDX, IDC_CUST_CART, ce_cart);

	Product *temp = nullptr;
	CStringW s = NULL;

	for (int i = 0; i < pList->size(); i++){
		temp = pList->elementAt(i);
		s += temp->getFullDisplay() + _T("\r\n");
	}
	ce_cart.SetWindowText(LPCTSTR(s));
	
}