-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler-driver.cpp
64 lines (55 loc) · 1.23 KB
/
scheduler-driver.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
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
#include "scheduler.h"
// Made by Dakshin Rathan
void makeUppercase(string &str)
{
for (char &c : str)
c = toupper(c);
}
int main()
{
Scheduler schedule;
string cmd, opt;
unsigned time, duration;
schedule.printSchedule();
cin >> cmd;
makeUppercase(cmd);
while (cmd != "QUIT")
{
if (cmd == "CANCEL")
{
cin >> time;
schedule.free(time);
schedule.printSchedule();
}
else if (cmd == "ADD")
{
time = duration = -1;
string temp;
//add EVENT from X to Y
cin >> opt >> temp >> time >> temp >> duration;
makeUppercase(opt);
duration -= time;
if (opt == FREE)
cout << "Cannot add event " << FREE << ": use cancel instead" << endl;
else if (schedule.isAvailable(time, duration))
{
schedule.schedule(opt, time, duration);
cout << "Added to schedule" << endl;
}
else
cout << "Scheduling conflict: not added" << endl;
schedule.printSchedule();
}
else if (cmd == "PRINT")
schedule.printSchedule();
cin.clear();
cin.ignore(10000, '\n');
cin >> cmd;
makeUppercase(cmd);
}
return 0;
}