Example #1
0
int main()
{
    std::vector<Quote> v;
    for (auto i=1; i!= 10; ++i)
        v.push_back(Bulk_quote("sss",i*10.1,10,0.3));
    double total = 0;
    for (const auto& b: v)
    {
        total += b.net_price(20);
    }
    std::cout << "total: " << total << std::endl;
    std::cout << "=======================\n\n";


    std::vector<std::shared_ptr<Quote>> pv;
    for (auto i=1; i!=10; ++i)
        pv.push_back(std::make_shared<Bulk_quote>
                (Bulk_quote("sss",i*10.1,10,0.3)));
    double total_p =0;
    for (const auto& p : pv)
    {
        total_p += p->net_price(20);
    }
    std::cout << "total_p: " << total_p << std::endl;

    return 0;
}
Example #2
0
int main()
{
	
	Basket car;
	car.add_items(Quote("0001", 25));
	car.add_items(Bulk_quote("0002", 12, 8, 0.3));
	car.add_items(Quote("0003", 19));
	car.add_items(Bulk_quote("0004", 32, 12, 0.5));
	auto total = car.total_receipt(std::cout);

	return 0;
}
Example #3
0
int main()
{
    Basket basket;

    for (unsigned i = 0; i != 10; ++i)
        basket.add_item(Bulk_quote("Bible",20.6,20,0.3));

    for (unsigned i = 0; i != 10; ++i)
        basket.add_item(Bulk_quote("C++Primer",30.9,5,0.4));

    for (unsigned i = 0; i != 10; ++i)
        basket.add_item(Quote("CLRS",40.1));

    std::ofstream log("log.txt",std::ios_base::app|std::ios_base::out);

    basket.total_receipt(log);
    return 0;
}
Example #4
0
int main()
{
    /**
     * @brief ex15.28   outcome == 9090
     */
    std::vector<Quote> v;
    for(unsigned i =1; i != 10; ++i)
        v.push_back(Bulk_quote("sss", i * 10.1, 10, 0.3));

    double total = 0;
    for (const auto& b : v)
    {
        total += b.net_price(20);
    }
    std::cout << total << std::endl;

    std::cout << "======================\n\n";

    /**
     * @brief ex15.29   outccome == 6363
     */
    std::vector<std::shared_ptr<Quote>> pv;

    for(unsigned i =1; i != 10; ++i)
        pv.push_back(std::make_shared<Bulk_quote>(Bulk_quote("sss", i * 10.1, 10, 0.3)));

    double total_p = 0;
    for (auto p : pv)
    {
        total_p +=  p->net_price(20);
    }
    std::cout << total_p << std::endl;

    return 0;

}