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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
#include <iostream>
#include <string>
#include <ctime>
#include <fstream>
#include <vector>
using namespace std;
string mondaylessons, tuesdaylessons, wednesdaylessons, thursdaylessons, fridaylessons, saturdaylessons, sundaylessons;
string computerapproom, programmingroom, codesroom, mathsroom, fundamentalsroom, softwareroom;
string computerappfreq, programmingfreq, codesfreq, mathsfreq, fundamentalsfreq, softwarefreq;
void findlessons(int weekday);
void findroom(int count1);
void findlecurer(int count2);
int main()
{
//outputting header
cout << "\t\t\t\t----------------" << endl;
cout << "\t\t\t\tTimeTable Intel" << endl;
cout << "\t\t\t\t----------------" << endl << endl;
//reading each line of text file and assigning it to a variable
ifstream read("lessons.txt");
if (read.is_open())
{
getline(read, mondaylessons);
getline(read, tuesdaylessons);
getline(read, wednesdaylessons);
getline(read, thursdaylessons);
getline(read, fridaylessons);
getline(read, saturdaylessons);
getline(read, sundaylessons);
}
ifstream read2("rooms.txt");
if (read2.is_open())
{
getline(read2, computerapproom);
getline(read2, programmingroom);
getline(read2, codesroom);
getline(read2, mathsroom);
getline(read2, fundamentalsroom);
getline(read2, softwareroom);
}
ifstream read3("lecturers.txt");
if (read3.is_open())
{
getline(read3, computerapproom);
getline(read3, programmingroom);
getline(read3, codesroom);
getline(read3, mathsroom);
getline(read3, fundamentalsroom);
getline(read3, softwareroom);
}
//getting the current day
time_t rawtime;
tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
int weekday = timeinfo->tm_wday;
//outputting the current lessons on the current day
cout << "Todays Lessons" << endl;
findlessons(weekday);
string input;
//setting up string to hold input data, and asking the user to input data
cout << "What would you like help with today?" << endl;
getline(cin, input);
cout << endl;
//user is able to ask what lessons are on a certain day
vector<string> days = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };
int count = 0;
while (count < days.size())
{
if ((input.find(days[count]) != string::npos) && input.find("lesson") != string::npos)
{
findlessons(count+1);
}
count++;
}
//users are able to ask what room a certain class is in
vector<string> lessons = { "computer", "programming", "codes", "maths", "fundamentals", "software"};
int count1 = 0;
while (count1 < lessons.size())
{
if ((input.find(lessons[count1]) != string::npos) && input.find("room") != string::npos)
{
findroom(count1+1);
}
count1++;
}
//users are able to ask which lecturers take a certain class
int count2 = 0;
while (count2 < lessons.size())
{
if ((input.find(lessons[count2]) != string::npos) && input.find("lecturer") != string::npos)
{
findlecurer(count2 + 1);
}
count2++;
}
while (true);
return 0;
}
void findlessons(int weekday)
{
//function to get a certain days lessons
switch (weekday)
{
case 1:
cout << mondaylessons << endl << endl;
break;
case 2:
cout << tuesdaylessons << endl << endl;
break;
case 3:
cout << wednesdaylessons << endl << endl;
break;
case 4:
cout << thursdaylessons << endl << endl;
break;
case 5:
cout << fridaylessons << endl << endl;
break;
case 6:
cout << saturdaylessons << endl << endl;
break;
case 7:
cout << sundaylessons << endl << endl;
break;
}
}
void findroom(int count1)
{
//function to get a certain lessons room
switch (count1)
{
case 1:
cout << computerapproom << endl << endl;
break;
case 2:
cout << programmingroom << endl << endl;
break;
case 3:
cout << codesroom << endl << endl;
break;
case 4:
cout << mathsroom << endl << endl;
break;
case 5:
cout << fundamentalsroom << endl << endl;
break;
case 6:
cout << softwareroom << endl << endl;
break;
}
}
void findlecturer(int count2)
{
//function to get a certain lessons room
switch (count2)
{
case 1:
cout << computerapproom << endl << endl;
break;
case 2:
cout << programmingroom << endl << endl;
break;
case 3:
cout << codesroom << endl << endl;
break;
case 4:
cout << mathsroom << endl << endl;
break;
case 5:
cout << fundamentalsroom << endl << endl;
break;
case 6:
cout << softwareroom << endl << endl;
break;
}
}
|