program Quizz; uses crt, sysutils; type TabPts = array [1..2] of integer; type Tabstring = array[1..50,1..3] of string; var TabQR : TabString; Numero:String; function Menu ():String; { Affiche le Menu } var reponse1 : Integer; reponse2 : Integer; reponse3 : Integer; a,b : char; c : string; begin write (' QUIZZ '); writeln(' Pour lire les règles taper 1 '); writeln(' Pour Jouer taper 2'); readln(reponse1); if (reponse1<>1) and (reponse1<>2) then repeat writeln('veuillez entrer une commande correcte'); readln(reponse1); until (reponse1=1) or (reponse1=1); if reponse1= 1 then writeln('Ce jeu consiste en un quizz. Vous pouvez choisir plusieurs modes de jeu : Normal, Thématique ou bien chronométré, chacun comportant 3 choix spécifiques.') else begin writeln('A quel mode de jeu souhaitez vous jouez ?'); writeln('1-Mode Normal'); writeln('2-Mode Thématique'); writeln('3-Mode Chronométré'); writeln('Entrez le chiffre correspondant'); readln(reponse2); if (reponse2<>1) and (reponse2<>2) and (reponse2<>3) then repeat writeln('Veuillez entrer une commande correcte'); read(reponse2); until (reponse2=1) or (reponse2=2) or (reponse2=3); end; if reponse2=1 then begin writeln ('Quelle difficulté voulez vous choisir'); writeln('1-Facile'); writeln('2-Medium'); writeln('3-Difficile'); writeln('Entrez le chiffre correspondant'); readln(reponse3); if (reponse3<>1) and (reponse3<>2) and (reponse3<>3) then repeat writeln('Veuillez entrer une commande correcte'); readln(reponse3); until (reponse3=1) or (reponse3=2) or (reponse3=3); end; if reponse2=2 then begin writeln ('Quelle thème voulez vous choisir'); writeln('1-Sport'); writeln('2-Cinéma'); writeln('3-Science'); writeln('Entrez le chiffre correspondant'); readln(reponse3); if (reponse3<>1) and (reponse3<>2) and (reponse3<>3) then repeat writeln('Veuillez entrer une commande correcte'); readln(reponse3); until (reponse3=1) or (reponse3=2) or (reponse3=3); end; if reponse2=3 then begin writeln ('Quelle temps voulez vous choisir'); writeln('1-1 minute'); writeln('2-2 minute'); writeln('3-3 minute'); writeln('Entrez le chiffre correspondant'); readln(reponse3); if (reponse3<>1) and (reponse3<>2) and (reponse3<>3) then repeat writeln('Veuillez entrer une commande correcte'); readln(reponse3); until (reponse3=1) or (reponse3=2) or (reponse3=3); end; a:=IntToStr(reponse2)[1]; b:=IntToStr(reponse3)[1]; c:=a+b; Menu:=c; clrscr(); end; { Menu } procedure Qaleatoire (var TabQR : Tabstring; var Numero: String); {Stock chaque question, (en fonction du thème choisi ) ses réponses et sa bonne réponse dans un tableau où chaque ligne correspondra à une question} var FicQ : text; var FicR :text; var FicBR : text; var i:integer; begin Numero:= Menu(); assign(FicQ,'Questions'+Numero+'.txt'); reset(FicQ); assign(FicR,'Reponses'+Numero+'.txt'); reset(FicR); assign(FicBR,'BonnesReponses'+Numero+'.txt'); reset(FicBR); for i:=1 to 50 do begin readln(FicQ,TabQR[i][1]); readln(FicR,TabQR[i][2]); readln(FicBR, TabQR [i][3]); end; close (FicBR); close (FicQ); close (FicR); end; { Qaleatoire } function AfficheQuestion (TabQR : Tabstring) : string; {Affiche aléatoirement une question et ses réponses parmi les 50 rentrées} var Quest, Rep : string; var BoRep : string; var ligne : integer; begin Randomize; ligne:=random(51); if ligne=0 then ligne:=ligne+1; Quest:=TabQR[ligne][1]; Rep:=TabQR[ligne][2]; BoRep:=TabQR[ligne][3]; writeln(Quest); writeln(Rep); AfficheQuestion := BoRep; end; { AfficheQuestion } function Repondre () : string; {Saisis la réponse du joueur} var reponse : string; begin writeln (' '); writeln ('Entrez le caractere de votre reponse entre a, b, c ou d'); readln (reponse); if (reponse <> 'a') and (reponse <> 'b') and (reponse <> 'c') and (reponse <> 'd') then begin writeln ('Vous avez entre une reponse impossible, rejouez'); Repondre () end else Repondre := reponse; end; { Repondre } function Comparaison (BoRep : string) : boolean; {Compare la réponse du joueur à la bonne réponse de la question} var bon : boolean; begin if (BoRep) = (Repondre ()) then bon := true else bon := false; Comparaison := bon; end; { Comparaison } function ReponseBonne (BoRep : string) : integer; {Attribut un nombre de points suivant si la réponse est bonne ou mauvaise} var PointsDonnes : integer; begin if (Comparaison (BoRep) = true) then PointsDonnes := 100 else PointsDonnes := 0; ReponseBonne := PointsDonnes; clrscr(); end; { ReponseBonne } procedure AfficherScore(PointTotal:Integer); begin writeln('Votre Score est de',PointTotal,'Points'); end; procedure Tour1 (TabQR:TabString); {Effectue un tour de jeu classique ou à thème et affiche le nombre de points} var PointQuestion, PointTotal : Integer; begin PointTotal:=0; repeat PointQuestion:=0; AfficheQuestion(TabQR); PointQuestion := ReponseBonne(Repondre()); PointTotal:=PointTotal+PointQuestion; until PointQuestion=0; AfficherScore(PointTotal); end; { Tour1 } procedure ChoixTour (Menu : string, TabQR:TabString); {Choisit Quel type de Tour choisir} begin if (Menu='11')or(Menu='12')or(Menu='13')or(Menu='21')or(Menu='22')or(Menu='23') then Tour1(TabQR) else Tour2(Menu,TabQR); end; { ChoixTour } procedure Son(ReponseBonne :Integer ); {Joue un Son suivant si la réponse est bonne ou fausse } begin if ReponseBonne<>0 then PlaySound ('miss-left.wav', 0, SND_ASYNC) else PlaySound ('bounce.wav', 0, SND_ASYNC); end; { Son } procedure Tour2(TabQR:TabString); begin PointTotal:=0; repeat PointQuestion:=0; AfficheQuestion(TabQR); PointQuestion := ReponseBonne(Repondre()); PointTotal:=PointTotal+PointQuestion; until Time=0; AfficherScore(PointTotal); end; { Tour2 } {Programme Principal} begin Qaleatoire(TabQR,Numero); ChoixTour(Numero); end. {Modifier pour la procédure son, créer différents répertoires, Tour2, jokers}