void putQA()
{
int choice,flag,temp,rrJay;
int forAmt=0,y,question;
long records;
IFstream qKbc;
randomize();
qKbc.open("kbcque.dat",ios::in|ios::binary);
if(qKbc.fail()!=0)
{
closegraph();
cout<<"nError finding KBCQUE.DAT";
exit(1);
}
//records=(qKbc.fileSize()/KBCQUE_RECLEN);
forAmt=0;
setrgbpalette(CYAN,0,0,40);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(CENTER_TEXT,CENTER_TEXT);
y=294;
while(1)
{
rrJay=random(100);
if(forAmt>14)
history();
// Playing for amount
setcolor(WHITE);
setfillstyle(SOLID_FILL,CYAN);
setcolor(CYAN);
rectangle(midx+71,y,maxx-1,y-12);
floodfill(midx+72,y-5,WHITE);
question=getQuestionNumber();
// After this check for repeat of question number
if(qKbc.eof())
qKbc.clear();
qKbc.seekg(question*KBCQUE_RECLEN);
qKbc.read((char*)&q,sizeof(QUE));
q.right--;
// Put choice numbers
setcolor(WHITE);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(40,400,"A.");
outtextxy(350,400,"B.");
outtextxy(40,450,"C.");
outtextxy(350,450,"D.");
// Put question and answers
outtextxy(midx,332,q.ques);
outtextxy(160,400,q.ans[0]);
outtextxy(475,400,q.ans[1]);
outtextxy(160,450,q.ans[2]);
outtextxy(475,450,q.ans[3]);
if(rrJay>40 && rrJay<70)
amitabhSpeaks(0);
CHOICE:
do
{
OUT_OF_LIFE: choice=getch();
choice=toupper(choice);
setviewport(1,1,midx+69,308,0);
clearviewport();
setviewport(0,0,maxx,maxy,0);
if(choice=='L')
{
LIFE: settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
temp=textheight("I");
outtextxy(midx/2,20,"Life Line Select");
settextjustify(LEFT_TEXT,CENTER_TEXT);
outtextxy(20,50+temp,"1: Audience poll");
outtextxy(20,50+temp*2,"2: Call the computer");
outtextxy(20,50+temp*3,"3: Fifty fifty");
choice=getch();
if(choice==27)
{
setviewport(1,1,midx+69,308,0);
clearviewport();
setviewport(0,0,maxx,maxy,0);
goto OUT_OF_LIFE;
}
choice-='0';
if(lifeLine[choice-1]==0 || !(choice>=1 && choice <=3))
{
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(midx/2,50+temp*6,"Sorry! Already used!");
delay(1000);
setcolor(BLACK);
outtextxy(midx/2,50+temp*6,"Sorry! Already used!");
setcolor(WHITE);
goto LIFE;
}
setviewport(1,1,midx+69,308,0);
clearviewport();
setviewport(0,0,maxx,maxy,0);
switch(choice)
{
case 1:
useLifeLine(1);
break;
case 2:
useLifeLine(2);
break;
case 3:
useLifeLine(3);
break;
}
}
if(choice==27)
leaveGame(forAmt-1);
}while(!(choice>='A' && choice<='D'));
choice-='A';
setviewport(1,1,midx+69,308,0);
clearviewport();
setviewport(0,0,maxx,maxy,0);
if(rrJay<50)
flag=amitabhSpeaks(1);
if(flag==0)
goto CHOICE;
flag=givenAns(q.right,choice);
if(!flag)
{
answer(1,forAmt-1);
gameOver(forAmt-1);
}
answer(0,forAmt);
forAmt++;
choice=99;
//Remove previous Q/A
setcolor(BLACK);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(midx,332,q.ques);
outtextxy(160,400,q.ans[0]);
outtextxy(475,400,q.ans[1]);
outtextxy(160,450,q.ans[2]);
outtextxy(475,450,q.ans[3]);
// Remove previous Blue strip
setfillstyle(SOLID_FILL,;
setcolor(WHITE);
rectangle(midx+71,y,maxx-1,y-12);
floodfill(midx+74,y-5,WHITE);
setcolor(BLACK);
rectangle(midx+71,y,maxx-1,y-12);
y-=(8+7);
}
}
объясните мне че он делаит по работе надо
|
|