1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| class Question
{
private:
//static int N;
char *quest;
char *proposition1;
char *proposition2;
char *proposition3;
char *proposition4;
char *reponse;
int Nb_point;
public:
Question();
Question(char*,char*,char*,char*,char*,char*,int);
Question(const Question& Q);
~Question();
//static int getN();
char* getQuestion();
char* getProposition1();
char* getProposition2();
char* getProposition3();
char* getProposition4();
char* getReponse();
int getNb_point();
void setQuestion(char*);
void setProposition1(char*);
void setProposition2(char*);
void setProposition3(char*);
void setProposition4(char*);
void setReponse(char*);
void setNb_point(int );
};
vector <Question> connexion()// cette fonction vas recuperer tous les question et il vas les stocker dans un vector de type question
{
vector <Question> Q;
Question Q1;
//ouverture de fichier questions.txt
ifstream fichierEntree("Questions.txt", ios::in);
if (!fichierEntree)
{
cout << "Problème douverture de fichier des question" << endl;
}
else
{
char* rep;
char* aux;
int choix;
char buf[1024];
while (!fichierEntree.eof())// tant que on a pas etaint la fin de fichier on vas:
{
fichierEntree.getline(buf, 1024);// recupurer ligne par ligne et stocker les info dans la variable Q1
Q1.setQuestion(buf);
fichierEntree.getline(buf, 1024);
Q1.setProposition1(buf);
fichierEntree.getline(buf, 1024);
Q1.setProposition2(buf);
fichierEntree.getline(buf, 1024);
Q1.setProposition3(buf);
fichierEntree.getline(buf, 1024);
Q1.setProposition4(buf);
fichierEntree.getline(buf, 1024);
Q1.setReponse(buf);
fichierEntree.getline(buf, 1024);
choix=atoi(buf);
Q1.setNb_point(choix);
Q.push_back(Q1);//Ici, comme on a déjà definit le consturcteur par recopie on vas le stockerdans la fin de vector comme ça on vas pas prendre bcp de temps
}
// Fermeture du fichier
system("pause");
fichierEntree.close();
}
} |
Partager