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
|
#include<iostream>
using namespace std;
struct course
{
string name;
int num_days;
char *days;
int start_hr, start_min;
int end_hr, end_min;
};
void get_info(struct course * courses, int num_cour);
void _free(struct course* courses, int num_cour);
void Help();
void pr(struct course *courses, int num_cour);
void pri(struct course *courses, int num_cour);
void prii(struct course *courses, int num_cour);
void priii(struct course *courses, int num_cour);
void priiii(struct course *courses, int num_cour);
void time(struct course *courses, int num_cour);
void conflict(struct course * courses,int num_cour);
int main(){
course *courses;
int num_cour;
cout << " ****************************************************** \n";
/***** here i get the number of the courses ***/
cout << "pls enter number of course:"; cin>> num_cour;
courses = new course[num_cour];
get_info(courses, num_cour);
pr(courses, num_cour);
pri(courses, num_cour);
prii(courses, num_cour);
priii(courses, num_cour);
priiii(courses, num_cour);
_free(courses, num_cour);
cout << " ****************************************************** \n";
return 0;
}
/***** in this function i get the names of the courses and the days ******/
void get_info(struct course* courses, int num_cour)
{
for(int i=0; i< num_cour; i++)
{
cout << "name:";
cin>> courses[i].name;
cout << "How many days" << endl;
cin>> courses[i].num_days;
courses[i].days=new char[courses[i].num_days];
for(int x=0; x < courses[i].num_days ; x++){
Help();
cout << "Enter the day" << endl;
cin >> courses[i].days[x];
}
}
time(courses, num_cour); // this is a call for another function that asks the user to enter the time of the courses when it starts and ends.
}
/******* this function prints out the courses on Mondays only ****/
void pr(struct course *courses, int num_cour){
cout << "** On Monday **\n";
for(int i=0; i<num_cour; i++){
for(int x=0; x<5;x++){
if(courses[i].days[x]=='m'){
cout << courses[i].name<<": " << courses[i].start_hr << ":"<< courses[i].start_min << "-" << courses[i].end_hr<< ":" << courses[i].end_min<< endl;
}
}
}
}
/******* this function prints out the courses on tusdays only ****/
void pri(struct course *courses, int num_cour){
cout << "** On Tusday **\n";
for(int i=0; i<num_cour; i++){
for(int x=0; x<5;x++){
if(courses[i].days[x]=='t'){
cout << courses[i].name<<": " << courses[i].start_hr << ":"<< courses[i].start_min << "-" << courses[i].end_hr<< ":" << courses[i].end_min<< endl;
}
}
}
}
/******* this function prints out the courses on Wednesday only ****/
void prii(struct course *courses, int num_cour){
cout << "** On Wednesday **\n";
for(int i=0; i<num_cour; i++){
for(int x=0; x<5;x++){
if(courses[i].days[x]=='w'){
cout << courses[i].name<<": " << courses[i].start_hr << ":"<< courses[i].start_min << "-" << courses[i].end_hr<< ":" << courses[i].end_min<< endl;
}
}
}
}
/******* this function prints out the courses on thursdays only ****/
void priii(struct course *courses, int num_cour){
cout << "** On Thursday **\n";
for(int i=0; i<num_cour; i++){
for(int x=0; x<5;x++){
if(courses[i].days[x]=='r'){
cout << courses[i].name<<": " << courses[i].start_hr << ":"<< courses[i].start_min << "-" << courses[i].end_hr<< ":" << courses[i].end_min<< endl;
}
}
}
}
/******* this function prints out the courses on fridays only ****/
void priiii(struct course *courses, int num_cour){
cout << "** On Friday **\n";
for(int i=0; i<num_cour; i++){
for(int x=0; x<5;x++){
if(courses[i].days[x]=='f'){
cout << courses[i].name<<": " << courses[i].start_hr << ":"<< courses[i].start_min << "-" << courses[i].end_hr<< ":" << courses[i].end_min<< endl;
}
}
}
}
/**** this function to frees out the memory ******/
void _free(struct course* courses, int num_cour)
{
for(int i=0; i<num_cour; i++)
{
delete [] courses[i].days;
}
delete [] courses;
}
void Help(){
cout <<"*** NOTE: ENTER (m) for Monday, (t) Tusday, (w) Wednesday, (r) Thursday, (f) Friday ***\n";
}
/******* this function is to get the time where the course starts and ends and it is also been called in an earlier function ****/
void time(struct course *courses, int num_cour){
for( int i=0; i<num_cour; i++){
cout << " at what hour is your "<< courses[i].name << " class start: ";
cin >> courses[i].start_hr;
cout << " at what minute is your "<< courses[i].name << " class start: ";
cin >> courses[i].start_min;
cout << " at what hour is your "<< courses[i].name << " class end: ";
cin >> courses[i].end_hr;
cout << " at what minute is your "<< courses[i].name << " class end: ";
cin >> courses[i].end_min;
}
}
void conflict(struct course * courses, int num_cour){
}
|