-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWarehouse.hpp
52 lines (41 loc) · 978 Bytes
/
Warehouse.hpp
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
#pragma once
#include <vector>
#include "Product.hpp"
#include "VehicleManager.hpp"
class Warehouse
{
private:
int Capacity = 0;
std::vector<Product> Stored;
public:
const size_t GetStoredCount() const
{
return Stored.size();
}
Warehouse& operator=(const Warehouse&) = delete;
Warehouse() = delete;
Warehouse(int NewCapacity) : Capacity(NewCapacity)
{
Stored.reserve(Capacity);
}
void FillStorage(std::vector<Product>& NewProducts)
{
for (const auto& Product : NewProducts)
{
if (Stored.size() >= Capacity)
{
std::cout << "Warehouse overflowed!\n";
break;
}
Stored.push_back(Product);
}
}
bool IsCloseToFull()
{
return ((Stored.size() * 100) / Capacity) > 95.0f;
}
void DispatchVehicles(VehicleManager& Manager)
{
Manager.DispatchCollection(Stored);
}
};