-
Notifications
You must be signed in to change notification settings - Fork 1
/
purchase.h
82 lines (67 loc) · 2.13 KB
/
purchase.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// Created by joaog on 12/21/2020.
//
#ifndef PROJETO1_PURCHASE_H
#define PROJETO1_PURCHASE_H
#include <string>
using namespace std;
/**
* @brief A Purchase is defined by the Viewer's name, the number of products in the purchase and the availability of the Viewer
*/
class Purchase {
/**
* @brief Name of the viewers who wants to purchase merch
*/
string name;
/**
* @brief Number of products in the purchase
*/
int numOfProducts;
/**
* @brief Availability of the Viewer
*/
int availability;
public:
/**
* @brief Constructs a new Purchase with given name, number of products and user's availability
* @param name Name of the Viewers
* @param numOfProducts Number of products ordered
* @param availability Availability of the Viewer
*/
Purchase(string name, int numOfProducts, int availability);
/**
* @brief Gets the name of the Viewer buying merch
* @return String containing the name of the Viewer
*/
string getName() const;
/**
* @brief Gets the number of products in the purchase
* @return Number of products
*/
int getNumOfProducts() const;
/**
* @brief Gets the availability of the Viewer
* @return Availability of the Viewer
*/
int getAvailability() const;
/**
* @brief Compares two purchases and checks which has less products and more availability
* @param p2 Second purchase to be compared
* @return True if this is has more products than p2 or less availability in case of a draw. False otherwise
*/
bool operator<(const Purchase& p2) const; // operators need this exact format
/**
* @brief Checks if the name of this is the same as p2's
* @param p2 Second purchase to be compared
* @return True if the name is the same and false otherwise
*/
bool operator==(const Purchase& p2) const;
};
/**
* @brief Prints the information of a purchase to a given stream
* @param out Stream to printed to
* @param p Purchase to be printed
* @return Out stream given
*/
ostream& operator<<(ostream& out, Purchase p);
#endif //PROJETO1_PURCHASE_H