I have a problem with a recursion in my program.
I want to randomly find a word in a list of words, but I want the word to have fewer than six letters if the difficulty level is on "easy", and more than six for level "hard".
I know I'm supposed to have a break point, but since I don't know how many times it might loop before the user finds a good word, I don't know what to do.
How can I terminate my recursion?
private void trouverMot()
{
var random = new Random();
int index = random.Next(0,maList.Count);
mot = (maList[index].Trim());
if(niveau == "Facile")
{
if(mot.Length > 6 || lstUse.Contains(mot))
{
trouverMot();
}
}else
{
if(mot.Length < 6 || lstUse.Contains(mot))
{
trouverMot();
}
}
lstUse.Add(mot);
affichage();
}