-
Notifications
You must be signed in to change notification settings - Fork 1
/
Package.h
136 lines (112 loc) · 3.7 KB
/
Package.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef PACKAGE_H
#define PACKAGE_H
#include <string>
#include <vector>
using namespace std;
//! Priority enum for package type
enum class Priority{
REGULAR = 1,
TWO_DAY,
OVERNIGHT
};
class Client;
//! Package class
/*!
* This Package class defines a package which was sent by a Client and received by a Client. Each package has a priority, a weight, and two clients (a sender and receiver).
*/
class Package{
//! Insertion Operator
/*!
* \param output output stream
* \param pack package object to print
* \return output stream
*/
friend std::ostream& operator<<(ostream& output, const Package& pack);
public:
//! Constructor
/*! Creates a package object to track client info, such as address and coordinates. Also track
* package age and IDs.
* \param s Client pointer to sender object.
* \param r Client pointer to receiver object.
* \param w Weight of package in ounces.
* \param p Priority enum of package (overnight, two-day, regular?)
* \param ID ID number of package. Used in the future to build adjacency matrix.
* \param packAge The age of the package in days. New packages are born at age 1.
* \return NULL.
*/
Package(Client* s, Client* r, const float w, const Priority p, unsigned int ID, int packAge);
//! Sender setter
/*!
* \param s pointer to sender client
*/
void setSender(Client*);
//! Sender getter
/*!
* \return pointer to sender client
*/
Client* getSender() const;
//! Receiver setter
/*!
* \param r pointer to receiver client
*/
void setReceiver(Client*);
//! Receiver getter
/*!
* \return pointer to receiver client
*/
Client* getReceiver() const;
//! Package weight setter
/*!
* Throws error on negative weight.
* \param w Package weight
*/
void setWeight(const double);
//! Package Weight getter
/*!
* \return Package weight
*/
float getWeight() const;
//! Package Priority setter
/*!
* \param p Priority enum
*/
void setPriority(const Priority);
//! Package priority getter
/*!
* \return Package priority
*/
Priority getPriority() const;
//! Priority string getter
/*!
* Priority is an enum and hence is actually an int. Here's a nice way to print the string value.
* \return string of priority
*/
string getPriorityString() const;
//! Get this pointer to current package.
Package* getPointer() {return this;};
//! Get ID of package.
unsigned int getID() const {return ID;};
//! Set ID of package
void setID(unsigned int id) {ID = id;};
private:
//! Pointer to sender client
Client *sender;
//! Pointer to receiver client
Client *receiver;
//! Weight of package in ounces
float weight;
//! Priority enum of package
Priority priority;
//! Package delivered?
bool Delivered = false;
//! Package ID number.
unsigned int ID;
//! Package age in delivery days.
/*! Starts life at 1 for first day. 2 is second day, etc.
* Used for packages not previous delivered. If a package is not delivered
* (does not make the route cut) it's age is increased. This age is used to
* add a weight to the algorithm to favor long delayed packages.
*/
int age;
};
#endif //PACKAGE_H