-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput.cpp
163 lines (154 loc) · 3.53 KB
/
output.cpp
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <iostream>
#include "person.h"
#include "boost\date_time\gregorian\gregorian.hpp"
#include "output.h"
using namespace std;
using namespace boost;
void output(gregorian::date startDay, gregorian::date endDay, int numberOfPeople, vector<Person*> people, vector<gregorian::date> dates,bool personAvailable)
{
gregorian::date_duration dd(1);
int count;
/*for (gregorian::date i = startDay; i < endDay; i = i + dd)
{
cout << "The people who can work on " << i << " are as follows: " << endl;
count = 0;
for (int j = 0; j < numberOfPeople; j++)
{
dates = people[j]->getDate();
for (int k = 0; k < dates.size(); k++)
{
if (dates[k] == i)
{
personAvailable = true;
}
}
if (personAvailable)
{
cout << people[j]->getName() << endl;
count++;
}
if (j == numberOfPeople - 1 && count == 0)
{
cout << "No-one!" << endl;
}
personAvailable = false;
}
cout << endl;
}*/
//Assign people to dates
//If someone works has been assigned to two more dates than everyone else then stop assigning them on their available days until it's even again.
//Each person needs a 'how many times used value' to compare across all
//Every day needs a driver and two passengers or it's a no-go
//need a timesmore than everyone else
int timesUsed;
int numberOfDrivers;
int extraPeopleCount;
bool check, first, changed;
string peopleOfDay[3];
string extraPeople[16];
//vector of people for that specific day
//then I can use the vector of people to find the drivers and get rid of one of them for that day
//next time it happens this driver needs to replace the next driver
//
first = true;
for (gregorian::date i = startDay; i < endDay; i = i + dd)
{
changed = false;
cout << "The people working on " << i << " are as follows: " << endl;
if (first)
{
count = 0;
first = false;
extraPeopleCount = 0;
}
numberOfDrivers = 0;
for (int j = 0; j < numberOfPeople; j++)
{
int timesUsedCount = 0;
dates = people[j]->getDate();
for (int k = 0; k < dates.size(); k++)
{
if (dates[k] == i)
{
personAvailable = true;
}
}
if (personAvailable && count < 3)
{
peopleOfDay[count] = people[j]->getName();
count++;
}
else if (personAvailable && count >= 3)
{
extraPeople[extraPeopleCount] = people[j]->getName();
extraPeopleCount++;
}
personAvailable = false;
}
if (count < 3)
{
cout << "Not enough people available" << endl;
}
else if (count >= 3)
{
for (int l = 0; l < 3; l++)
{
cout << peopleOfDay[l] << endl;
}
cout << "Extra people are: ";
for (int l = 0; l < 16; l++)
{
if (extraPeople[l] != "")
{
cout << extraPeople[l] << " ";
}
}
cout << endl;
}
if (extraPeopleCount > 0)
{
if (extraPeopleCount > 3)
{
for (int y = 0; y < 3; y++)
{
peopleOfDay[y] = extraPeople[y];
extraPeople[y] = "";
}
for (int y = 0; y < 16; y++)
{
if (y + 3 < 16)
{
if (changed == false && extraPeople[y+3] == "")
{
extraPeopleCount = y;
changed = true;
}
extraPeople[y] = extraPeople[y + 3];
}
}
count = 3;
}
else{
for (int y = 0; y < extraPeopleCount; y++)
{
peopleOfDay[y] = extraPeople[y];
extraPeople[y] = "";
count = extraPeopleCount;
}
for (int y = 0; y < 16; y++)
{
if (y + extraPeopleCount < 16)
{
extraPeople[y] = extraPeople[y + extraPeopleCount];
}
}
extraPeopleCount = 0;
}
}
else
{
count = 0;
}
cout << endl;
}
};