#include #include #include #include #include #include #include char a[5]; FILE *fp=fopen("log.txt","w+t"); //----------------------Log class--------------------------------------- class Log { public: int questionsAsked; Log() { questionsAsked=0; } void setLog(int qask) { questionsAsked=qask; if(questionsAsked<5 && questionsAsked>0) { fprintf(fp,"\n'1.1.1:[SetLog]$ 'Log' @ 'NotCovered'"); cout<<"Log NotCovered"; } else if(questionsAsked==5) { fprintf(fp,"\n'1.1.1:[SetLog]$ 'Log' @ 'Covered'"); cout<<"Log Covered"; }else { fprintf(fp,"\n'1.1.1:[SetLog]$ 'Log' @ 'Undefined'"); cout<<"\n log is set to undefined state"; } } }; Log l; //object of log class //----------------------Result class------------------------------------ class Result { public: int count; Result() { count=0; } void setResult(int wh) { char b[]={'A','B','C','D','A'}; if(wh<5 && wh>=0) { for(int i=0;i<=1;i++); if(a[wh]==b[wh]) { count++; } if(count<3 && count>=0) { fprintf(fp,"\n'1.1.2:[SetResult]$ 'Result' @ 'NotQualified'"); cout<<"\n NotQualified"; } else if(count>=3 && count<=5) { fprintf(fp,"\n'1.1.2:[SetResult]$ 'Result' @ 'Qualified'"); cout<<"\n Qualified"; } else { fprintf(fp,"\n'1.1.2:[SetResult]$ 'Result' @ 'undefined'"); } } else { fprintf(fp,"\n'1.1.2:[SetResult]$ 'Result' @ 'undefined'"); cout<<"size of ans char is exceed......."; } gd.setGrade(count); fprintf(fp,"\n'1.1.2:[SetResult]$ 'Result' @ 'undefined'"); } }; Result s; //----------------------display_question class-------------------------- class display_question { public: void question(int n) { fprintf(fp,"\n"); char ans='\0'; switch(n) { case 1: { fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Display_Question'"); cout<<"\nQ.1: question 1\n"; cout<<"(A) (B) (C) (D)\nAns: "; cin>>ans; a[0]=ans; l.setLog(1); s.setResult(0); fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Undefined'"); } break; case 2: { fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Display_Question'"); cout<<"\nQ.2: question 2\n"; cout<<"(A) (B) (C) (D)\nAns: "; cin>>ans; a[1]=ans; l.setLog(2); s.setResult(1); fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Undefined'"); } break; case 3: { fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Display_Question'"); cout<<"\nQ.3: question 3\n"; cout<<"(A) (B) (C) (D)\nAns: "; cin>>ans; a[2]=ans; l.setLog(3); s.setResult(2); fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Undefined'"); } break; case 4: { fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Display_Question'"); cout<<"\nQ.4: question 4\n"; cout<<"(A) (B) (C) (D)\nAns: "; cin>>ans; a[3]=ans; l.setLog(4); s.setResult(3); fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Undefined'"); } break; case 5: { fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Display_Question'"); cout<<"\nQ.5: question 5\n"; cout<<"(A) (B) (C) (D)\nAns: "; cin>>ans; a[4]=ans; l.setLog(5); s.setResult(4); fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Undefined'"); } break; default: { fprintf(fp,"\n'1.1:[Question]$ 'Display_Question' @ 'Undefiend'"); cout<<"not match any case in question"; } } } }; display_question dsp; //----------------------Gradeobtained class------------------------------------- class Gradeobtained { public: char choice; int gra; Gradeobtained() { gra=0; //gra o menas novice, 1=>intermedite, 2=expert } void setGrade(int count) { Gradeobtained gd; //-----------------------------Grade is set on the basis of solved questions----- if(count<=2) { gra=0; } else if(count<5 && count>2) { gra=1; } else if(count==5) { gra=2; } else { fprintf(fp,"\n'1.1.2.1:[setGrade]$ 'Gradeobtained '@ 'Undefined'"); cout<<"invalid count variable found...grade is set to Undefined state"; } //--------------------------here gra is check ---------- if(gra==0) { fprintf(fp,"\n'1.1.2.1:[SetGrade]$ 'Gradeobtained' @ 'Novice'"); cout<<"\nyou are navice \n"; cout<<"\n do you want to update your grade\n"; cin>>choice; if(choice=='Y' && l.questionsAsked<5) { gd.updatePerformance((l.questionsAsked)+1); fprintf(fp,"\n'1.1.2.1:[setGrade]$ 'Gradeobtained '@ 'Undefined'"); getch(); exit(1); } else { getch(); exit(1); } } else if(gra==1) { fprintf(fp,"\n'1.1.2.1:[SetGrade]$ 'Gradeobtained' @ 'Intermediate'"); cout<<"\nyou are intermediate \n"; cout<<"\ndo you want update your grade\n"; cin>>choice; if(choice=='Y' && l.questionsAsked<5) { gd.updatePerformance((l.questionsAsked)+1); fprintf(fp,"\n'1.1.2.1:[setGrade]$ 'Gradeobtained '@ 'Undefined'"); getch(); exit(1); } else { if(l.questionsAsked==5) { cout<<"sorry !!!! Log is full try next time"<>id; cout<<"Enter password: \n"; cin>>password; if(!cin.good()) { fprintf(fp,"\n'1:[Start]$ 'LoginUser' @ 'password_not_int_type'"); cout<<"please enter password in integer "; cin.clear(); getch(); exit(1); // logi.start(); } logi.check(id,password); //call check function of login class } }; LoginUser logi; //----------------------main method------------------------------------- void main() { clrscr(); logi.start(); getch(); }