forked from jedbrooke/CIS-22C-Team-4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrder.h
101 lines (67 loc) · 2.38 KB
/
Order.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
/*
* Order.h
* Andrew Maxwell
*/
#ifndef ORDER_H_
#define ORDER_H_
#include "BST.h"
#include "SubOrder.h"
#include "Customer.h"
#include <ctime>
using namespace std;
class Customer;
class Order {
private:
Customer * customer;
List<subOrder> laptops;
int shippingSpeed;
time_t timePlaced, arriveBy;
bool placed, shipped;
float price;
public:
/** constructors */
Order();
Order(Customer * customer);
Order(istream &in, BST <Product> &products, Customer * customer);
/** getters */
string getArriveBy() const;
//returns the date that the order should arrive, determined based on day order is placed and shipping speed
string getDayPlaced() const;
//returns the date the order was placed
int getShippingSpeed() const;
//returns the shipping speed
float getPrice() const;
//returns the total price of all of the items.
bool isPlaced() const;
//returns whether the order has been placed or not
bool isShipped() const;
//returns whether the order has been shipped. If the order has been shipped, no further modification is allowed.
bool isDelivered() const;
/** setters */
void ship();
//sets the order to shipped. Should only be called by Heap, not manually.
void addLaptop(Product * newLaptop);
//Adds a new laptop. If laptop matches existing laptop, increment by 1. Changes price of order.
//Pre: !isShipped
void addLaptop(string laptopKey);
void removeLaptop(int index);
//removes a laptop from the list, by index. Changes price of order.
//Pre: !isShipped
//Pre: Index < length of list
//(check for these before calling the function, so that you can display a user-friendly error message)
void setQuantity(int index, int quant);
//changes the quantity variable for laptop at index. If quantity is 0, removes laptop.
void placeOrder(int daysToShip);
//places the order; sets it as ready to ship. Should only be called by Heap, not manually.
bool operator>(const Order&);
//Compares orders based on when they need to ship. Used for priority queue.
bool operator<(const Order&);
bool operator>=(const Order&);
bool operator<=(const Order&);
string print();
string printDetailed();
void save(ostream & out);
Order * load(istream & in, BST<Product> & products);
friend ostream& operator<<(ostream& out, const Order& order) ;
};
#endif /* ORDER_H_ */