-
Notifications
You must be signed in to change notification settings - Fork 0
/
Company.h
132 lines (99 loc) · 3.33 KB
/
Company.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
#pragma once
#include<iostream>
class UI;
#include"VIPTruck.h"
#include"NormalTruck.h"
#include"SpecialTruck.h"
#include"Event.h"
#include"Time.h"
#include"Queue.h"
#include"Truck.h"
#include"List.h"
enum MODES { DAY, NIGHT };
class Company
{
//properties of similation
Time currentTime;
string IN_PATH;
string OUT_PATH;
ofstream out_file;
UI* uiPtr;
//counters
int NormalTruckCount, SpecialTruckCount, VIPTruckCount; //count all trucks in company
int MovingCargoCount;//count moving Cargos Count
int MaxW, AutoP, J; // j no of journeys till maintaince
//Types of Trucks By Priority of assignment of [Normal-VIP ] cargos
const Types Cargo_VIP_PRIORITY[3] = { VIP, Normal, Special };
const Types Cargo_NORMAL_PRIORITY[2] = { Normal, VIP };
//Statitics
Time TotalCargoWait;
int TotalTruckActiveTime, PromotedCargoCount;
double TotalTruckUtilization;
//..........................Lists..........................//
Queue<Event *> EventList;
//Trucks Lists
//type of empty Trucks
PriorityQueue<Truck *> emptyTrucks [2][3];
//PriorityQueue<Truck*> NightTrucks[3];
PriorityQueue<Truck *> maintainingTrucks[2][3];
List<Truck *> loadingTrucks;
PriorityQueue< Truck*>* movingTrucks;
//Cargos Lists
LinkedList<Cargo*> waitingNormalCargo;
Queue<Cargo*> waitingSpecialCargo;
PriorityQueue<Cargo*> waitingVIPCargo;
Queue<int> DeliveredCargos[3]; //then store it's ID in DeliveredCargos according to it's type
// to print it in UI
//..........................Lists..........................//
//..........................Function of Company..........................//
bool NightMode() const;//bool to konw if Company not in working hours
inline bool isSimulationEnd();//bool check if all trucks and cargos and events end
void load();//call it in Constructor
//read INPUT_FILE.txt
//Inialize all Data Read in .txt
//create new Trucks and pass input file to it
void EndSimulation();
void Out_End();
void ExecuteEvent();
//Loading Trucks & assign
void assign(bool isNight = false);
//moving
void moveTrucks();
void AddWaitingCargo(Cargo* temp);
void DeliverCargos();
//checkups
void EndCheckUP();
//Auto promotion
void AutoPromotion();
void Promote(Cargo *);
//Trucks from move to checkUP || Empty
void checkLoadingTrucks();
bool addLoadingTruck(Truck* t, Types CargoType, int MinCapacity, bool Now, PriorityQueue<Truck*>* choosenTruckList);
void TrucksReturnBack();
//
int getTotalTruckCount() const;
public:
Company();
void Simulate();
//..........Getters......//
int getWaitingCargosCount() const;
int getMovingCargosCount() const;
int getLoadingTrucksCount() const;
int* getEmptyTrucksCount() const;
int getNightTrucksCount() const;
int* getMaintainingTrucksCount() const;
int getDeliveredCargosCount() const;
const Time& getCurrentTime() const;
//........Getters Of Cargos.....//
LinkedList<Cargo*>& getWaitingNormalCargo();
Queue<Cargo*>& getWaitingSpecialCargo();
PriorityQueue<Cargo*>& getWaitingVIPCargo();
const Queue<int>* getDeliveredCargo() const;
//........Getters Of Trucks....//
const PriorityQueue<Truck*>* getEmptyTrucks(int) const;
const PriorityQueue< Truck*>* getMaintainingTrucks(int) const;
const PriorityQueue<Truck*>* getNightTrucks() const;
const List<Truck*>& getLoadingTrucks() const;
const PriorityQueue< Truck*>* getMovingTrucks() const;
~Company();
};