New logic added, June 3, 2026
This commit is contained in:
parent
e2bcf46be7
commit
487912116e
1 changed files with 32 additions and 5 deletions
|
|
@ -10,14 +10,15 @@ public class Game
|
||||||
private static int index = rnd.Next(1, Words.FiveLetterWords.Count);
|
private static int index = rnd.Next(1, Words.FiveLetterWords.Count);
|
||||||
private static string solution = Words.FiveLetterWords[index];
|
private static string solution = Words.FiveLetterWords[index];
|
||||||
private static bool exit = false;
|
private static bool exit = false;
|
||||||
public void validateFiveLetters(string solution)
|
public void validateFiveLetters(string solutionCheck)
|
||||||
{
|
{
|
||||||
|
exit = false;
|
||||||
while (exit == false)
|
while (exit == false)
|
||||||
{
|
{
|
||||||
if (solution.Length != 5)
|
if (solutionCheck.Length != 5)
|
||||||
{
|
{
|
||||||
index = rnd.Next(1, Words.FiveLetterWords.Count);
|
index = rnd.Next(1, Words.FiveLetterWords.Count);
|
||||||
|
solution = Words.FiveLetterWords[index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -26,21 +27,47 @@ public class Game
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validateFiveLettersAttempt(string attemptCheck)
|
||||||
|
{
|
||||||
|
exit = false;
|
||||||
|
while (exit == false)
|
||||||
|
{
|
||||||
|
if (attemptCheck.Length != 5)
|
||||||
|
{
|
||||||
|
attempt = AnsiConsole.Ask<string>("Your word is not exactly 5 letters. Try again.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string attempt = AnsiConsole.Ask<string>("What is your [green]name[/]?");
|
||||||
private List<char> attemptList;
|
private List<char> attemptList;
|
||||||
|
private List<char> solutionList;
|
||||||
|
|
||||||
private void createCharList(string solution)
|
private void createCharList(string solution)
|
||||||
{
|
{
|
||||||
foreach (char c in solution)
|
foreach (char c in solution)
|
||||||
|
{
|
||||||
|
solutionList.Add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createAttemptCharList(string attempt)
|
||||||
|
{
|
||||||
|
foreach (char c in attempt)
|
||||||
{
|
{
|
||||||
attemptList.Add(c);
|
attemptList.Add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Game()
|
public Game()
|
||||||
{
|
{
|
||||||
validateFiveLetters(solution);
|
validateFiveLetters(solution);
|
||||||
|
validateFiveLettersAttempt(attempt);
|
||||||
createCharList(solution);
|
createCharList(solution);
|
||||||
|
createAttemptCharList(attempt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue