Changes with notes.

This commit is contained in:
Jocelyn Hebert 2026-06-03 18:37:01 -03:00
commit 83cdc58672
5 changed files with 92 additions and 64 deletions

View file

@ -0,0 +1,24 @@
namespace Lingo;
public class DisplayCharacters
{
private char letter;
public char Letter {
get;
private set
{
// Capital A is 65, to 90, 97-122
if (((int)value >= 65 && (int)value <= 90) || ((int)value <= 122 && (int)value >= 97))
{
letter = value;
}
else
{
}
}
}
}

View file

@ -1,23 +1,29 @@
using System.Reflection.Metadata.Ecma335;
using System.Security.Cryptography;
using Spectre.Console;
namespace Lingo;
public class Game
{
private int count = 0;
//This should only be the data, not the logic.
public int count = 0;
static Random rnd = new Random();
private static int index = rnd.Next(1, Words.FiveLetterWords.Count);
private static string solution = Words.FiveLetterWords[index];
private static bool exit = false;
public void validateFiveLetters(string solutionCheck)
public static int index = rnd.Next(1, Words.FiveLetterWords.Count);
public string solution = Words.FiveLetterWords[index];
public static bool exit = false;
public string attempt;
private List<char> attemptList;
private List<char> solutionList;
public void ValidateFiveLetters(string solutionCheck)
{
exit = false;
while (exit == false)
{
if (solutionCheck.Length != 5)
{
index = rnd.Next(1, Words.FiveLetterWords.Count);
index = rnd.Next(0, Words.FiveLetterWords.Count);
solution = Words.FiveLetterWords[index];
}
else
@ -27,14 +33,15 @@ public class Game
}
}
public void validateFiveLettersAttempt(string attemptCheck)
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.");
attempt = AnsiConsole.Ask<string>("[red]Your word is not exactly 5 letters. Try again.[/]");
attemptCheck = attempt;
}
else
{
@ -43,31 +50,39 @@ public class Game
}
}
public static string attempt = AnsiConsole.Ask<string>("What is your [green]name[/]?");
private List<char> attemptList;
private List<char> solutionList;
private void createCharList(string solution)
public void checking (string tries)
{
foreach (char c in solution)
for (int i = 0; i < tries.Length; i++)
{
solutionList.Add(c);
if (tries[i] == solution[i])
{
//Green
}
else if (solution.Contains(tries[i]))
{
//Yellow
}
else
{
// black
}
}
}
private void createAttemptCharList(string attempt)
public void askForInput()
{
foreach (char c in attempt)
{
attemptList.Add(c);
}
attempt = AnsiConsole.Ask<string>("Enter a 5-letter word");
}
public Game()
{
validateFiveLetters(solution);
validateFiveLettersAttempt(attempt);
createCharList(solution);
createAttemptCharList(attempt);
}
}

View file

@ -2,10 +2,5 @@ namespace Lingo;
public class Play
{
public Play()
{
}
public int I { get; private set; }
//Put the logic here, methods. Controlling the game loop.
}

View file

@ -5,40 +5,33 @@ using Spectre.Console;
class Program
{
static void Main(string[] args)
{
try
{
bool isRunning = true;
{ //Make a view class instead of stuffing it here.
// Game controller could have the game loop? try this.
// Also an input controller, instead of putting it in view or others.
bool isRunning = true;
do
AnsiConsole.Clear();
string userSelection = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("Choose play or quit ")
.AddChoices
(
"1. Play Lingo",
"2. Quit"
)
);
switch (userSelection)
{
AnsiConsole.Clear();
case "1. Play Lingo":
Game game = new Game();
string userSelection = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("Choose play or quit ")
.AddChoices
(
"1. Play Lingo",
"2. Quit"
)
);
switch (userSelection)
{
case "1. Play Lingo":
Game attempt = new Game();
break;
case "2. Quit":
break;
}
break;
case "2. Quit":
isRunning = false;
break;
}
} while (isRunning);
}
catch (Exception ex)
{
AnsiConsole.MarkupLine($"[red]Error:[/] {ex.Message}");
Console.ReadLine();
}
}
}

View file

@ -2,7 +2,8 @@ namespace Lingo;
public static class Words
{
public static readonly List<string> FiveLetterWords = new List<string>
//Readonly collection? Interface
public static List<string> FiveLetterWords = new List<string>
{
"joust", "swamp", "glint", "prawn", "chide", "stomp", "fleck", "groan",
"birch", "thrum", "slunk", "brave", "chops", "twirl", "plank", "snore", "draft", "gloom", "wharf", "spunk",