ajout de 3 fonctions
This commit is contained in:
@@ -87,30 +87,31 @@ void curseur(bool interrupteur) {
|
|||||||
1 - JOUER
|
1 - JOUER
|
||||||
====================================*/
|
====================================*/
|
||||||
//fonction pour choisir le mot de facon random
|
//fonction pour choisir le mot de facon random
|
||||||
void choisirMot(string nomFichier, int maximum) {
|
void afficherMenuJouer()
|
||||||
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() {
|
|
||||||
cout << setw(83) << "=============================================\n";
|
cout << setw(83) << "=============================================\n";
|
||||||
string motPlayer;
|
string motPlayer;
|
||||||
do
|
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
cout << setw(69) << "Saisir votre mot : ";
|
do
|
||||||
cin >> motPlayer;
|
{
|
||||||
} while (motPlayer.length() > 3);
|
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;
|
cout << setw(66) << "Votre mot est : " << motPlayer;
|
||||||
|
|||||||
@@ -33,3 +33,5 @@ void choisirMot(string nomFichier, int maximum);
|
|||||||
string goToLine(fstream& monFlux, int numeroLigne);
|
string goToLine(fstream& monFlux, int numeroLigne);
|
||||||
|
|
||||||
void afficherMenuJouer();
|
void afficherMenuJouer();
|
||||||
|
bool dansListe(string motPlayer);
|
||||||
|
bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne);
|
||||||
Reference in New Issue
Block a user