-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExer15_28_29_Limit_quote.h
48 lines (48 loc) · 1.36 KB
/
Exer15_28_29_Limit_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
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef LIMIT_QUOTE_H
#define LIMIT_QUOTE_H
#include <cstddef>
#include <utility>
#include "Exer15_28_29_Disc_quote.h"
class Limit_quote : public Disc_quote {
public:
// inherited constructor
using Disc_quote::Disc_quote;
Limit_quote() = default;
// overrides the base version in order to implement the bulk purchase discount policy
double net_price(std::size_t) const override;
void debug() const override;
// copy-control members
Limit_quote(const Limit_quote &lq) : Disc_quote(lq) {}
Limit_quote(Limit_quote &&lq) : Disc_quote(std::move(lq)) {}
Limit_quote& operator=(const Limit_quote&);
Limit_quote& operator=(Limit_quote&&);
~Limit_quote()=default; // virtual by inheritance
};
inline
double Limit_quote::net_price(std::size_t cnt) const
{
if(cnt <= quantity)
return cnt * (1 - discount) * price;
else
return cnt * price;
}
inline void Limit_quote::debug() const
{
std::cout << "std::string bookNo\n"
<< "double price\n"
<< "std::size_t max_qty\n"
<< "double discount\n"
<< std::endl;
}
Limit_quote& Limit_quote::operator=(const Limit_quote &rhs)
{
Disc_quote::operator=(rhs);
return *this;
}
Limit_quote& Limit_quote::operator=(Limit_quote &&rhs)
{
if(this != &rhs)
Disc_quote::operator=(std::move(rhs));
return *this;
}
#endif