Beruflich Dokumente
Kultur Dokumente
CPP
/*
#include
#include
#include
#include
#include
<fstream.h>
<conio.h>
<stdio.h>
<string.h>
<process.h>
Catechize.CPP
float perc;
void getuser(); // Get data about the user
void showuser() // Show data about the user
{
cout<<endl<<"Displaying Player Details..."
<<endl<<"Name: "<<nm
<<endl<<"Age: "<<age
<<endl<<"Sex: "<<sex
<<endl<<"Score: "<<score
<<endl<<"Passes: "<<pass
<<endl<<"Percentage Accuracy: "<<perc<<endl;
}
char *retname() // Return private data member 'nm'
{
return nm;
}
int retage() // Return private data member 'age'
{
return age;
}
char retsex() // Return private data member 'sex'
{
return sex;
}
void checkuser();
} u1, u2;
void user::getuser()
{
do
{
flag=0;
clrscr();
cout<<endl<<"DON'T PANIC!"
<<endl<<"Enter username (maximum 40 characters): ";
gets(nm);
strcpy(check,nm);
file.open("user.dat", ios::in|ios::binary);
while (file.read((char*)&u2, sizeof(u2)))
{
strcpy(name,u2.retname());
if(strcmpi (check,name) == 0)
{
flag = 1;
cout<<endl<<"Username already exist!!";
cout<<endl<<"Press any key to continue";
getch();
break;
}
}
file.close();
}while(flag==1);
cout<<"Enter age: ";
cin>>age;
cout<<"Enter sex (M/F): ";
cin>>sex;
if (sex == 'm') // To standardise the database
sex = 'M';
else if (sex == 'f')
sex = 'F';
score = 0;
pass = 0;
Catechize.CPP
perc = 0.0;
}
Catechize.CPP
Catechize.CPP
Catechize.CPP
file.close();
file.open("user.dat", ios::in|ios::binary);
while (file.read((char*)&u1, sizeof(u1)))
{
if (u1.score == r1)
{
u1.showuser();
cout<<endl<<"Press any key to continue...";
getch();
}
}
file.close();
break;
case 2 :
float p1, p2;
p1 = u1.perc;
while (file.read((char*)&u1, sizeof(u1)))
{
p2 = u1.perc;
if (p2 > p1)
p1 = p2;
}
cout<<endl<<"Highest Accuracy Percentage is: "<<p1
<<endl<<"Details of user(s) with high score: ";
file.close();
file.open("user.dat", ios::in|ios::binary);
while (file.read((char*)&u1, sizeof(u1)))
{
if (u1.perc == p1)
{
u1.showuser();
cout<<endl<<"Press any key to continue...";
getch();
}
}
file.close();
break;
default :
cout<<endl<<"You entered an incorrect choice!";
break;
}
}
Catechize.CPP
Catechize.CPP
r1++;
if (r1 != r2)
temp.write((char*)&q1, sizeof(q1));
else
{
q1.showq();
cout<<endl<<"Is this the question you want to delete? (Y/N): ";
cin>>cch;
if (cch == 'n' || cch == 'N')
{
temp.write((char*)&q1, sizeof(q1));
cout<<endl<<"Question has not been deleted"<<endl;
cout<<endl<<"Press any key to continue...";
getch();
file.close();
temp.close();
goto admindel;
}
}
}
file.close();
temp.close();
remove("ques.dat");
rename("temp.dat", "ques.dat");
}
void qmmode() // Quizmaster Mode - For viewing all questions with answers
{
cout<<endl<<"Entering Quizmaster Mode"
<<endl<<"This displays all questions in the database along with the answer";
file.open("ques.dat", ios::in|ios::binary);
while(file.read((char*)&q1, sizeof(q1)))
{
clrscr();
q1.showq();
r1 = q1.retans();
cout<<endl<<"Option number "<<r1<<" is correct"
<<endl<<"Press any key to continue (or '0' to exit QM mode)...";
cch = getch();
if (cch == '0')
break;
}
file.close();
}
Catechize.CPP
while (!file.eof())
{
r1++;
cch = file.get();
cout<<cch;
if ( (r1%930) == 0)
{
cout<<endl<<endl<<"Press any key to continue (or '0' to exit this
mode)..."<<endl<<endl;
cch = getch();
if (cch == '0')
break;
}
}
file.close();
cout<<endl<<endl<<"Press any key to continue...";
getch();
}
Catechize.CPP
Catechize.CPP
switch(ich)
{
case 0 :
case 1 :
goto end;
qmmode();
break;
case 2 :
addq();
break;
case 3 :
editq();
break;
case 4 :
delq();
break;
case 5 :
countq();
cout<<endl<<"The database has "<<r3<<" questions";
cout<<endl<<endl<<"Press any key to continue...";
getch();
break;
case 6 :
viewusers();
break;
case 7 :
searchuser();
break;
case 8 :
edituser();
break;
case 9 :
deluser();
break;
case 10 :
highscore();
break;
case 11 :
pswd();
break;
case 12 :
proghelp();
break;
default :
cout<<endl<<"You entered an invalid choice!";
}
goto admenu;
}
end:
cout<<endl<<"You are about to exit Catechize Administrator Menu"
<<endl<<"Press any key to continue...";
getch();
}
Catechize.CPP
break;
aboutus();
break;
case 0 :
cout <<endl<<"Thank you for using Catechize , this software
was developed by : \n \t \t \t Deepanshu Goyal & Jayveer Singh " ;
getch();
exit(0);
default :
cout<<endl<<"You entered an invalid choice!";
case 4 :
}
goto menu;
}