forked from pezy/CppPrimer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex15_15_Bulk_quote.h
36 lines (25 loc) · 922 Bytes
/
ex15_15_Bulk_quote.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
=================================================================================
C++ Primer 5th Exercise Answer Source Code
Copyright (C) 2014-2015 github.com/pezy/Cpp-Primer
Disc_quote
If you have questions, try to connect with me: pezy<[email protected]>
=================================================================================
*/
#ifndef CP5_EX15_15_BULK_QUOTE_H_
#define CP5_EX15_15_BULK_QUOTE_H_
#include "ex15_15_Disc_quote.h"
#include <string>
inline namespace EX15 {
using std::string;
class Bulk_quote : public Disc_quote {
public:
Bulk_quote() = default;
Bulk_quote(string const& book, double price, size_t qty, double disc) : Disc_quote(book, price, qty, disc) { }
virtual double net_price(std::size_t cnt) const override {
if (cnt >= quantity) return cnt * (1 - discount) * price;
else return cnt * price;
}
};
}
#endif // CP5_EX15_15_BULK_QUOTE_H_