本文整理匯總了C++中Basket::total_receipt方法的典型用法代碼示例。如果您正苦於以下問題:C++ Basket::total_receipt方法的具體用法?C++ Basket::total_receipt怎麽用?C++ Basket::total_receipt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Basket
的用法示例。
在下文中一共展示了Basket::total_receipt方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: MockBulk
TEST(CxxCaseQuote, MockBulk)
{
using namespace case_quote;
// Bulk_quote sales which has discount: minimum 5 and 25% discount
// 35*6*(1-.25) = 157.5
shared_ptr<MockBulk> q1(new MockBulk("912", 35, 5, .25));
shared_ptr<MockBulk> q2(new MockBulk("912", 35, 5, .25));
shared_ptr<MockBulk> q3(new MockBulk("912", 35, 5, .25));
shared_ptr<MockBulk> q4(new MockBulk("912", 35, 5, .25));
shared_ptr<MockBulk> q5(new MockBulk("912", 35, 5, .25));
EXPECT_CALL(*q1, net_price(_))
.WillOnce(Return(157.5));
Basket sale;
sale.add_item(q1);
sale.add_item(q2);
sale.add_item(q3);
sale.add_item(q4);
sale.add_item(q5);
EXPECT_EQ(sale.total_receipt(cout), 157.5);
}
示例2: main
int main()
{
Basket sale;
sale.add_item(shared_ptr<Quote>(new Quote("123", 45)));
sale.add_item(shared_ptr<Quote>(new Quote("123", 45)));
sale.add_item(shared_ptr<Quote>(new Quote("123", 45)));
sale.add_item(make_shared<Bulk_quote>("345", 45, 3, .15));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("345", 45, 3, .15)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("345", 45, 3, .15)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("345", 45, 3, .15)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("345", 45, 3, .15)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("345", 45, 3, .15)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("345", 45, 3, .15)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("345", 45, 3, .15)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("678", 55, 5, .25)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("678", 55, 5, .25)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("678", 55, 5, .25)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("678", 55, 5, .25)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("678", 55, 5, .25)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("678", 55, 5, .25)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("678", 55, 5, .25)));
sale.add_item(shared_ptr<Quote>(new Bulk_quote("678", 55, 5, .25)));
sale.add_item(shared_ptr<Quote>(new Lim_quote("abc", 35, 2, .10)));
sale.add_item(shared_ptr<Quote>(new Lim_quote("abc", 35, 2, .10)));
sale.add_item(shared_ptr<Quote>(new Lim_quote("abc", 35, 2, .10)));
sale.add_item(shared_ptr<Quote>(new Lim_quote("abc", 35, 2, .10)));
sale.add_item(shared_ptr<Quote>(new Lim_quote("abc", 35, 2, .10)));
sale.add_item(shared_ptr<Quote>(new Lim_quote("abc", 35, 2, .10)));
sale.add_item(shared_ptr<Quote>(new Quote("def", 35)));
sale.add_item(shared_ptr<Quote>(new Quote("def", 35)));
sale.total_receipt(cout);
Basket bsk;
// arguments are the ISBN, price, minimum quantity, and discount
bsk.add_item(shared_ptr<Quote>(new Bulk_quote("0-201-82470-1", 50, 5, .19)));
bsk.add_item(shared_ptr<Quote>(new Bulk_quote("0-201-82470-1", 50, 5, .19)));
bsk.add_item(shared_ptr<Quote>(new Bulk_quote("0-201-82470-1", 50, 5, .19)));
bsk.add_item(shared_ptr<Quote>(new Bulk_quote("0-201-82470-1", 50, 5, .19)));
bsk.add_item(shared_ptr<Quote>(new Bulk_quote("0-201-82470-1", 50, 5, .19)));
bsk.add_item(shared_ptr<Quote>(new Lim_quote("0-201-54848-8", 35, 2, .10)));
bsk.add_item(shared_ptr<Quote>(new Lim_quote("0-201-54848-8", 35, 2, .10)));
bsk.add_item(shared_ptr<Quote>(new Lim_quote("0-201-54848-8", 35, 2, .10)));
bsk.total_receipt(cout);
}
示例3: main
int main()
{
Basket basket;
basket.add_item(Quote("0-201-82470-1", 50));
for (int i = 0; i < 15; ++i)
basket.add_item(Bulk_quote("0-201-54848-8", 50, 10, .25));
basket.total_receipt(cout);
return 0;
}
示例4: main
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;
}
示例5: MockQuote
TEST(CxxCaseQuote, MockQuote)
{
using namespace case_quote;
// Quote sales which has no discount, 45*3 = 135
std::shared_ptr<MockQuote> q1(new MockQuote("123", 45));
std::shared_ptr<MockQuote> q2(new MockQuote("123", 45));
std::shared_ptr<MockQuote> q3(new MockQuote("123", 45));
EXPECT_CALL(*q1, net_price(_))
.WillOnce(Return(135));
// when expects that net_price() gets called on q2 and q3 since net_price()
// will be called once.
//
// .cpp:169: Failure
// Actual function call count doesn't match EXPECT_CALL(*q3, net_price(_))...
// Expected: to be called once
// Actual: never called - unsatisfied and active
// t_ex_basket.cpp:166: Failure
// Actual function call count doesn't match EXPECT_CALL(*q2, net_price(_))...
// Expected: to be called once
// Actual: never called - unsatisfied and active
// [ FAILED ] BasketTest.checkTotal1 (2 ms)
//
// EXPECT_CALL(*q2, net_price(_))
// .WillOnce(Return(135));
//
// EXPECT_CALL(*q3, net_price(_))
// .WillOnce(Return(135));
// so change "Times" or comment them out
//
// EXPECT_CALL(*q2, net_price(_))
// .Times(AnyNumber())
// .WillOnce(Return(135));
//
// EXPECT_CALL(*q3, net_price(_))
// .Times(AnyNumber())
// .WillOnce(Return(135));
Basket sale;
sale.add_item(q1);
sale.add_item(q2);
sale.add_item(q3);
EXPECT_EQ(sale.total_receipt(cout), 135);
}
示例6:
TEST(CxxCaseQuote, Clone)
{
using namespace case_quote_clone;
Basket sale;
// Quote sales which has no discount. 45*3 = 135
sale.add_item(Quote("123", 45));
sale.add_item(Quote("123", 45));
sale.add_item(Quote("123", 45));
// minimum 3 and 15% discount. no discount 45*2 = 90
sale.add_item(Bulk_Quote("345", 45, 3, .15));
sale.add_item(Bulk_Quote("345", 45, 3, .15));
sale.total_receipt(cout);
}
示例7: main
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;
}