rework de tout le code

This commit is contained in:
William
2025-11-28 09:36:43 -05:00
parent 982a2edf88
commit 4e2b25c906
3 changed files with 44 additions and 46 deletions

View File

@@ -87,18 +87,15 @@ void curseur(bool interrupteur) {
1 - JOUER
====================================*/
//fonction pour choisir le mot de facon random
void choisirMot(string nomFichier, int maximum) {
system("cls");
string choisirMot(string nomFichier, int maximum) {//Choisi un mot al<61>atoire et le renvoi
int numeroLigne = rand() % (maximum)+1;
fstream monFlux;
ouvrirFichier(monFlux, nomFichier);
string mot = goToLine(monFlux, numeroLigne);
string motRandom = goToLine(monFlux, numeroLigne);
fermerFichier(monFlux);
return motRandom;
}
string goToLine(fstream& monFlux, int numeroLigne) {
string goToLine(fstream& monFlux, int numeroLigne) {//g<>n<EFBFBD>re un nb al<61>atoire, et choisi une ligne associ<63> pour un mot al<61>atoire. renvoi le mot choisi
string mot;
for (int i = 0; i < numeroLigne; i++) {
getline(monFlux, mot);
@@ -109,25 +106,25 @@ string goToLine(fstream& monFlux, int numeroLigne) {
void afficherMenuJouer()
{
cout << setw(83) << "=============================================\n";
string motPlayer;
for (int i = 0; i < 6; i++)
string motPlayer;
for (int nbTentative = 0; nbTentative < 6; nbTentative++)
{
do
{
cout << setw(65) << "Tentative #" << i + 1 << endl;
cout << setw(65) << "Tentative #" << nbTentative + 1 << endl;
cout << setw(69) << "Saisir votre mot : ";
cin >> motPlayer;
} while (motPlayer.length() > 3);
if (dansListe(motPlayer))
{
cout << "\na continue\n";
}
else
{
cout << setw(58) << "Mot n'est pas dans la liste";
i--;
cout << setw(58) << "\nMot n'est pas dans la liste\n";
nbTentative--;
}
}
@@ -136,27 +133,27 @@ void afficherMenuJouer()
cout << setw(66) << "Votre mot est : " << motPlayer;
}
bool dansListe(string motPlayer)
{
fstream monFlux;
ouvrirFichier(monFlux, "Mots/mot3lettres.txt");
comparerMot(monFlux, motPlayer, 15);
}
bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne)
{
string mot;
for (int i = 0; i < numeroLigne; i++) {
for (int i = 0; i < 15; i++) { //TODO changer le chiffre 15 par le num<75>ro de ligne dans le ficher
getline(monFlux, mot);
if (motPlayer == mot)
{
return true;
}
}
return false;
return false;
fermerFichier(monFlux);
}
/*====================================
2 - OPTIONS
====================================*/