|
From: Noorez K. <coo...@ho...> - 2004-08-27 05:55:31
|
#ifndef quiz_h //quiz.h
#define quiz_h
class Quiz
{
private:
char question[1000];
char answerA[1000];
char answerB[1000];
char answerC[1000];
char answerD[1000];
char answerT;
char answerF;
char actual;
public:
static int questionNumb;
static int type;
Quiz createQuestion();
void writeQuestion(Quiz ques, int type,char* quizName);
};
#endif
//quiz.h
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <conio.h>
#include <myfs.h>//this is mine, connects to my static lib
#include <conio.h>
using namespace std;
using namespace myf;
#include "Quiz.h"
int Quiz::questionNumb = 1;
int Quiz::type = 0;
Quiz Quiz::createQuestion()
{
Quiz ques;
cls();//lib function
cout << "What kind of question do you want question " <<
Quiz::questionNumb
<< " to be?\n";
real1:
cout << "A. Multiple choice or B. True/False [a\\b] ";
char choice;
choice=getche();//this char that is inputted
if(!(choice == 'a' || choice == 'b'))
{
cout << "\nChoice must be a or b\n";
goto real1;
}
if(choice == 'a')
{
type = 1;
cout << "\n\nType the question in\n\n";
cin.getline(ques.question,1000); //shows up hear as if i typed it
but didn't push enter
cout << "Type in answer A. ";
cin.getline(ques.answerA,1000);
cout << "Type in answer B. ";
cin.getline(ques.answerB,1000);
cout << "Type in answer C. ";
cin.getline(ques.answerC,1000);
cout << "Type in answer D. ";
cin.getline(ques.answerD,1000);
real2:
cout << "Give us the real answer [a\\b\\c\\d] ";
ques.actual=getche();
if(!(ques.actual == 'a' || ques.actual == 'b'
|| ques.actual == 'c' || ques.actual == 'd') )
{
cout << "\nReal answer must be a,b,c or d\n";
goto real2;
}
}
if(choice == 'b')
{
type = 2;
cout << "\n\nType in the statement\n\n";
cin.getline(ques.question,1000); //same hear
real3:
cout << "Give us the real answer [t\\f] ";
ques.actual=getche();
if(!(ques.actual == 't' || ques.actual == 'f'))
{
cout << "\nReal answer must be t or f\n";
goto real3;
}
}
return ques;
}
void Quiz::writeQuestion(Quiz ques, int type, char* quizName)
{
ofstream out_file(quizName,ios::app);
if(type == 1)
{
out_file << "~\n" << questionNumb << ". " << ques.question << '\n'
<< '\n';
out_file << "A. " << ques.answerA << '\n';
out_file << "B. " << ques.answerB << '\n';
out_file << "C. " << ques.answerC << '\n';
out_file << "D. " << ques.answerD << '\n';
out_file << '~' << ques.actual << '\n' << '|';
}
if(type == 2)
{
out_file << "~\n" << questionNumb << ". " << ques.question << '\n';
out_file << "True or False [t\\f]\n";
out_file << '~' << ques.actual << '\n' << '|';
}
}
on the marked lines i put some errors that i am getting in my program.
_________________________________________________________________
Take charge with a pop-up guard built on patented Microsoft® SmartScreen
Technology.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSN® Premium right now and get the
first two months FREE*.
|