diff --git a/Basic_Functions/addcourse.cpp b/Basic_Functions/addcourse.cpp new file mode 100644 index 0000000..9670a31 --- /dev/null +++ b/Basic_Functions/addcourse.cpp @@ -0,0 +1,32 @@ +#include +using namespace std; +void AddCourse(string codelist[],int creditlist[],int semesterlist[],string namelist[],string code,int credit,int semester,string name) +{ + if(isValidCourseCode(code)) + if(isValidCreditHours(credit)) + if(isValidSemester(semester)) + if(isValidCourseName(name)) + { + codelist[counter]=code; + creditlist[counter]=credit; + semesterlist[counter]=semester; + namelist[counter]=name; + counter++; + } + else + cout<<"INVALID COURSENAME"< +using namespace std; +void DeleteCourse(string codelist[],int creditlist[],int semesterlist[],string namelist[],string code) +{ + int o; + for(int i=0;i +using namespace std; +void EditCourse(string codelist[],int creditlist[],int semesterlist[],string namelist[],string code,int credit,int semester,string name) +{ + + if(isValidCourseCode(code)) + if(isValidCreditHours(credit)) + if(isValidSemester(semester)) + if(isValidCourseName(name)) + { + codelist[global]=code; + creditlist[global]=credit; + semesterlist[global]=semester; + namelist[global]=name; + } + else + cout<<"INVALID COURSENAME"< +#include +using namespace std; +bool loadCourses(string codelist[],string namelist[],int semesterlist[],int creditlist[]) +{ + string line; + int a; + ifstream file1; + file1.open("Courses.txt"); + if(file1.is_open()) + { + for(int i=0;!file1.eof();i++) + { + getline(file1,line,','); + if(isValidCourseCode(line)) + { + codelist[i]=line; + getline(file1,line,','); + if(isValidCourseName(line)) + { + namelist[i]=line; + file1>>a; + if(isValidCreditHours(a)) + { + creditlist[i]=a; + file1.ignore(1,','); + file1>>a; + if(isValidSemester(a)) + { + semesterlist[i]=a; + + counter++; + file1.ignore(1,'\0'); + } + else + { + cout< +#include +#include +using namespace std; +int counter1=0; +bool loadUsers(string userslist[],string passwordslist[]) +{ + string line; + ifstream user; + user.open("Users.txt"); + if(user.is_open()) + { + for(int i=0;!user.eof();i++) + { + getline(user,line,','); + userslist[i]=line; + cout<>username; + cout<>password; + cout< +#include +using namespace std; +void saveCourses(string codelist[],string namelist[],int semesterlist[],int creditlist[],) +{ + ofstream file; + file.open("Courses.txt"); + if(file.is_open()) + { + for(int i=0;i +using namespace std; +int searchcode(string code) +{ + bool flag=0; + for(int i=0;i +using namespace std; + +int main() +{ + string code; + cin>>code; + cout< +#include +using namespace std; +bool isValidCourseName(string coursename) +{ + bool flag=0; + int length=coursename.size(); + for(int i=0;i='A'&&coursename[i]<='Z')||(coursename[i]>='a'&&coursename[i]<='z')||coursename[i] == ' ') + flag=1; + else + return 0; + } + return 1; +} +int main() +{ + int a; + string name; + getline(cin,name); + cout< +#include +using namespace std; +bool isValidCreditHours(int credit) +{ + if(credit>0&&credit<4) + + return 1; + + else + + return 0; + +} +int main() +{ + int a; + cin>>a; + cout< +#include +using namespace std; +bool isValidSemester(int s) +{ + if(s>0&&s<9) + { + return 1; + } + else + { + return 0; + } +} +int main() +{ + int a; + cin>>a; + cout< +using namespace std; +void ViewCourses(string codelist[],int creditlist[],int semesterlist[],string namelist[]) +{ +for(int i=0;i +using namespace std; +void ViewSemesterCourses(string codelist[],int creditlist[],int semesterlist[],string namelist[],int semester) + +{ +for(int i=0;i