ajout de 3 fonctions

This commit is contained in:
William
2025-11-28 09:08:58 -05:00
parent 6cc93a7e01
commit d9cf833e0e
2 changed files with 25 additions and 22 deletions

View File

@@ -87,30 +87,31 @@ void curseur(bool interrupteur) {
1 - JOUER
====================================*/
//fonction pour choisir le mot de facon random
void choisirMot(string nomFichier, int maximum) {
int numeroLigne = rand() % (maximum)+1;
fstream monFlux;
ouvrirFichier(monFlux, nomFichier);
string mot = goToLine(monFlux, numeroLigne);
fermerFichier(monFlux);
}
string goToLine(fstream& monFlux, int numeroLigne) {
string mot;
for (int i = 0; i < numeroLigne; i++) {
getline(monFlux, mot);
}
return mot;
}
void afficherMenuJouer() {
void afficherMenuJouer()
{
cout << setw(83) << "=============================================\n";
string motPlayer;
do
for (int i = 0; i < 6; i++)
{
cout << setw(69) << "Saisir votre mot : ";
cin >> motPlayer;
} while (motPlayer.length() > 3);
do
{
cout << setw(65) << "Tentative #" << i + 1 << endl;
cout << setw(69) << "Saisir votre mot : ";
cin >> motPlayer;
} while (motPlayer.length() > 3);
if (dansListe(motPlayer))
{
}
else
{
cout << setw(58) << "Mot n'est pas dans la liste";
i--;
}
}
cout << setw(66) << "Votre mot est : " << motPlayer;

View File

@@ -33,3 +33,5 @@ void choisirMot(string nomFichier, int maximum);
string goToLine(fstream& monFlux, int numeroLigne);
void afficherMenuJouer();
bool dansListe(string motPlayer);
bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne);