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
|
void Scheduler::query(string user)
{
map <string,string> allocatedTime;
//Monday
allocatedTime.insert(pair<string,string>("0800","Monday"));
allocatedTime.insert(pair<string,string>("0900","Monday"));
allocatedTime.insert(pair<string,string>("1000","Monday"));
allocatedTime.insert(pair<string,string>("1100","Monday"));
allocatedTime.insert(pair<string,string>("1200","Monday"));
allocatedTime.insert(pair<string,string>("1300","Monday"));
allocatedTime.insert(pair<string,string>("1400","Monday"));
allocatedTime.insert(pair<string,string>("1500","Monday"));
allocatedTime.insert(pair<string,string>("1600","Monday"));
allocatedTime.insert(pair<string,string>("1700","Monday"));
allocatedTime.insert(pair<string,string>("1800","Monday"));
//Tuesday
allocatedTime.insert(pair<string,string>("0800","Tuesday"));
allocatedTime.insert(pair<string,string>("0900","Tuesday"));
allocatedTime.insert(pair<string,string>("1000","Tuesday"));
allocatedTime.insert(pair<string,string>("1100","Tuesday"));
allocatedTime.insert(pair<string,string>("1200","Tuesday"));
allocatedTime.insert(pair<string,string>("1300","Tuesday"));
allocatedTime.insert(pair<string,string>("1400","Tuesday"));
allocatedTime.insert(pair<string,string>("1500","Tuesday"));
allocatedTime.insert(pair<string,string>("1600","Tuesday"));
allocatedTime.insert(pair<string,string>("1700","Tuesday"));
allocatedTime.insert(pair<string,string>("1800","Tuesday"));
multiset <string> allocatedDay;
allocatedDay.insert("Monday");
allocatedDay.insert("Tuesday");
allocatedDay.insert("Wednesday");
allocatedDay.insert("Thursday");
allocatedDay.insert("Friday");
allocatedDay.insert("Saturday");
ifstream fileOpen;
fileOpen.open("schedule.txt");
string cName,getData,uName,topic,time,duration,day,person1,person2,getDay;
int counter=0;
cout<<"Please enter a colleague`s name:";
cin>>cName;
cout<<"Please enter a day:";
cin>>getDay;
while(!fileOpen.eof())
{
getline(fileOpen,getData);
if(getData.find(user)!=string::npos)
{
stringstream getInfo(getData);
getline(getInfo,uName,';');
if(uName==user)
{
for(int i=0;i<=counter;i++)
{
getline(getInfo,topic,';');
getline(getInfo,day,';');
getline(getInfo,time,';');
getline(getInfo,duration,';');
getline(getInfo,person1,',');
getline(getInfo,person2,',');
if(getData.find(cName)!=string::npos)
{
map <string,string>::iterator it;
if(day==getDay)
{
allocatedTime.erase(allocatedTime.find(time));
cout<<"The avaliable timings for"<<cName<<" on "<<getDay<<endl;
for(it=allocatedTime.begin();it!=allocatedTime.end();it++)
{
cout<<(*it).first<<endl;
}
}
}
}
counter++;
counter--;
}
}
}
fileOpen.close();
}
|