forked from jzplp/Cpp-Primer-Answer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quote.h
43 lines (31 loc) · 909 Bytes
/
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
#ifndef QUOTE_H
#define QUOTE_H
#include<iostream>
#include<string>
class Quote
{
public:
Quote() = default;
Quote(const std::string &book, double sales_price) : bookNo(book), price(sales_price) { }
std::string isbn() const { return bookNo; }
virtual double net_price(std::size_t n) const;
virtual ~Quote() = default;
virtual std::ostream & debug(std::ostream & os) const;
private:
std::string bookNo;
protected:
double price = 0.0;
};
class Bulk_quote : public Quote
{
public:
Bulk_quote() = default;
Bulk_quote(const std::string & book, double p, std::size_t qty, double disc) : Quote(book, p), min_qty(qty), discount(disc) { }
double net_price(std::size_t ) const override;
std::ostream & debug(std::ostream & os) const override;
private:
std::size_t min_qty = 0;
double discount = 0.0;
};
double print_total(std::ostream & os, const Quote & item, std::size_t cnt);
#endif