Exemplo n.º 1
0
bool operator<(const Product &prod1, const Product &prod2){
    string prod1Name = prod1.getName();
    string prod2Name = prod2.getName();
    if(prod1Name < prod2Name)
        return true;
    return false;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
void ProductOrder::print() {
    cout << "Name: " << prod.getName()
         << "\nPrice: "
         << prod.getPrice()
         << "\nQuantity: " << quantity
         << "\nTotal Amount: "
         << getTotal() << "\n";
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
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;
}
Exemplo n.º 6
0
void Store::readProducts()
{
	ifstream productsFile(fileNames[1]);
	Product product;
	unsigned int n;

	productsFile >> n;
	productsFile.ignore(INT64_MAX, '\n');

	for (size_t i = 0; i < n; i++)
	{
		productsFile >> product;
		productsFile.ignore(INT64_MAX, '\n');
		products.push_back(product);
		productsNamePointer[product.getName()] = productsPositionPointer[(unsigned int)i] = &(*products.rbegin());
		productsPointerPosition[&(*products.rbegin())] = (unsigned int)i;
	}

}
 // Metodo que exibe na tela o resumo das compras feitas e o valor total e o desconto
     void  purchaseResume()

    {
        
      Product * sweeper = firstProduct;
      sum = 0;

   
      
            while (sweeper != NULL)
             {
        
              cout<<sweeper->getID()<<"  "<<sweeper->getName()<<"  "<<setprecision(2)<<fixed<<sweeper->getPrice()<<endl;
              cout<<endl;
              sum += sweeper->getPrice();
              sweeper = sweeper->getNextProduct();
             }
         


     cout<<endl;
     cout<<endl;

           if(fixedDiscount)
            {
             cout<<"Descontos:   -"<<setprecision(2)<<fixed<<discount<<endl;
             cout<<endl;
             sum -= discount;
             cout<<"Total:        "<<setprecision(2)<<fixed<<sum<<endl;
            }
          else
            {
            discount = (discount/100)*sum;
            cout<<"Descontosp:   -"<<setprecision(2)<<fixed<<discount<<endl;
            cout<<endl;
            sum -= discount;
            cout<<"Total:        "<<setprecision(2)<<fixed<<sum<<endl;
            }

 
                      

    }
Exemplo n.º 8
0
bool cmpByName(const Product& p1, const Product& p2)
{
    return (strcmp(p1.getName(),p2.getName()))>0;
}