Skip to content

Commit

Permalink
Update ex15.7
Browse files Browse the repository at this point in the history
fixed a logic error in ex15.7
  • Loading branch information
Hao Zhixiang committed Jun 1, 2015
1 parent 885b319 commit d40ae9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion ch15/ex15.7/limit_quote.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#include "limit_quote.h"


double Limit_quote::net_price(std::size_t n) const
{
if (n > max_qty)
return max_qty * price * discount + (n - max_qty) * price;
else
return n * discount *price;
}
3 changes: 1 addition & 2 deletions ch15/ex15.7/limit_quote.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class Limit_quote : public Quote
Limit_quote(const std::string& b, double p, std::size_t max, double disc):
Quote(b,p), max_qty(max), discount(disc) { }

double net_price(std::size_t n) const override
{ return n * price * (n < max_qty ? 1 - discount : 1 ); }
double net_price(std::size_t n) const override;

private:
std::size_t max_qty = 0;
Expand Down

0 comments on commit d40ae9f

Please sign in to comment.