-
Notifications
You must be signed in to change notification settings - Fork 14
/
Sales_data.h
47 lines (33 loc) · 967 Bytes
/
Sales_data.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
#ifndef SALES_DATA_H
#define SALES_DATA_H
#include <iostream>
#include<string>
struct Sales_data;
Sales_data add(const Sales_data & sa, const Sales_data & sb);
std::istream & read(std::istream & is, Sales_data & sa);
std::ostream & print(std::ostream & os, const Sales_data & sa);
class Sales_data
{
friend Sales_data add(const Sales_data & sa, const Sales_data & sb);
friend std::istream & read(std::istream & is, Sales_data & sa);
friend std::ostream & print(std::ostream & os, const Sales_data & sa);
public:
Sales_data() = default;
Sales_data(const std::string &s) : ISBN(s) { }
Sales_data(const std::string &s, int a, double t) : ISBN(s), amount(a), totalPrice(t * a) { }
Sales_data(std::istream &is)
{
read(is, *this);
}
std::string isbn() const
{
return ISBN;
}
Sales_data & combine(const Sales_data & sa);
private:
std::string ISBN;
double totalPrice = 0.0;
int amount = 0;
inline double avg_price() const;
};
#endif