commit ac3dbe41696c18b0b212911fc920bcc390f65900 Author: Grizouille Date: Sat Dec 6 09:14:15 2025 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06723e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin/ +obj/ +.vscode +.vs \ No newline at end of file diff --git a/MiniJeuBourin/MiniJeuBourin.csproj b/MiniJeuBourin/MiniJeuBourin.csproj new file mode 100644 index 0000000..fd4bd08 --- /dev/null +++ b/MiniJeuBourin/MiniJeuBourin.csproj @@ -0,0 +1,10 @@ + + + + Exe + net9.0 + enable + enable + + + diff --git a/MiniJeuBourin/MiniJeuBourin.sln b/MiniJeuBourin/MiniJeuBourin.sln new file mode 100644 index 0000000..685875a --- /dev/null +++ b/MiniJeuBourin/MiniJeuBourin.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniJeuBourin", ".\MiniJeuBourin.csproj", "{7FD7F388-4E91-40A3-AF53-B91F6186B604}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Debug|x64.ActiveCfg = Debug|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Debug|x64.Build.0 = Debug|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Debug|x86.ActiveCfg = Debug|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Debug|x86.Build.0 = Debug|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Release|Any CPU.Build.0 = Release|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Release|x64.ActiveCfg = Release|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Release|x64.Build.0 = Release|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Release|x86.ActiveCfg = Release|Any CPU + {7FD7F388-4E91-40A3-AF53-B91F6186B604}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/MiniJeuBourin/Program.cs b/MiniJeuBourin/Program.cs new file mode 100644 index 0000000..a887471 --- /dev/null +++ b/MiniJeuBourin/Program.cs @@ -0,0 +1,70 @@ +// See https://aka.ms/new-console-template for more information +using System; +using System.Runtime.CompilerServices; + +class Program() +{ + private static Dictionary _scores; + + + + public static void Main() + { + Console.WriteLine("Bienvenue dans "); + Console.WriteLine("✊✋✌️ Pierre-Papier-Ciseaux !"); + Console.WriteLine("Premier à 3 points gagne !"); + PierrePapierCiseaux(); + + // Résultat final + Console.WriteLine($"\n{(_scores["joueur"] == 3 ? "🎉 TU AS GAGNÉ !" : "😢 L\'ordinateur a gagné...")}"); + Console.WriteLine($"Score final : {_scores["joueur"]} - {_scores["ordi"]}"); + } + + + + private static void PierrePapierCiseaux() + { + var random = new Random(); + var choix_possibles = new[] { "pierre", "papier", "ciseaux" }; + _scores = new Dictionary() + { + {"joueur", 0}, + {"ordi", 0} + }; + + while (_scores["joueur"] < 3 && _scores["ordi"] < 3) + { + Console.WriteLine($"\nScore : Toi {_scores["joueur"]} - {_scores["ordi"]} Ordinateur"); + Console.WriteLine("Choisis (pierre, papier, ciseaux) : "); + var joueur = Console.ReadLine().ToLower(); + + if (!choix_possibles.Contains(joueur)) + { + Console.WriteLine("❌ Choix invalide !"); + continue; + } + + + var ordi = random.GetItems(choix_possibles, 1).FirstOrDefault(); + Console.WriteLine($"🤖 L'ordinateur a choisi : {ordi}"); + + // Déterminer le gagnant + if (joueur == ordi) + { + Console.WriteLine("✨ Égalité !"); + } + else if ((joueur == "pierre" && ordi == "ciseaux") || + (joueur == "papier" && ordi == "pierre") || + (joueur == "ciseaux" && ordi == "papier")) + { + Console.WriteLine("✅ Tu gagnes cette manche !"); + _scores["joueur"] += 1; + } + else + { + Console.WriteLine("❌ L'ordinateur gagne cette manche !"); + _scores["ordi"] += 1; + } + } + } +} diff --git a/MiniJeux/MiniJeux.sln b/MiniJeux/MiniJeux.sln new file mode 100644 index 0000000..1cfc0f4 --- /dev/null +++ b/MiniJeux/MiniJeux.sln @@ -0,0 +1,53 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniJeux", "MiniJeux\MiniJeux.csproj", "{5BA674C8-192C-47C8-8F50-F9F17A762B2C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniJeux.Test", "Tests\MiniJeux.Test\MiniJeux.Test.csproj", "{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|x64.ActiveCfg = Debug|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|x64.Build.0 = Debug|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|x86.ActiveCfg = Debug|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|x86.Build.0 = Debug|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|Any CPU.Build.0 = Release|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|x64.ActiveCfg = Release|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|x64.Build.0 = Release|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|x86.ActiveCfg = Release|Any CPU + {5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|x86.Build.0 = Release|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|x64.ActiveCfg = Debug|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|x64.Build.0 = Debug|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|x86.ActiveCfg = Debug|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|x86.Build.0 = Debug|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|Any CPU.Build.0 = Release|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|x64.ActiveCfg = Release|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|x64.Build.0 = Release|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|x86.ActiveCfg = Release|Any CPU + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {09AF8FA9-D62B-45DB-AC87-0BAE32811EAC} = {0AB3BF05-4346-4AA6-1389-037BE0695223} + EndGlobalSection +EndGlobal diff --git a/MiniJeux/MiniJeux/MiniJeux.csproj b/MiniJeux/MiniJeux/MiniJeux.csproj new file mode 100644 index 0000000..fd4bd08 --- /dev/null +++ b/MiniJeux/MiniJeux/MiniJeux.csproj @@ -0,0 +1,10 @@ + + + + Exe + net9.0 + enable + enable + + + diff --git a/MiniJeux/MiniJeux/Pendu.cs b/MiniJeux/MiniJeux/Pendu.cs new file mode 100644 index 0000000..e5b8674 --- /dev/null +++ b/MiniJeux/MiniJeux/Pendu.cs @@ -0,0 +1,87 @@ +using System; + +public class Pendu +{ + public Pendu() + { + Start(); + } + + + private void Start() + { + string[] mots = { "ordinateur", "programmation", "developpement", "algorithmie", "variable" }; + Random random = new Random(); + string motSecret = mots[random.Next(0, mots.Length)]; + + char[] lettresTrouvees = new char[motSecret.Length]; + for (int i = 0; i < lettresTrouvees.Length; i++) + { + lettresTrouvees[i] = '_'; + } + + int vies = 7; + bool motComplet = false; + + Console.WriteLine("=== JEU DU PENDU ==="); + Console.WriteLine($"Le mot a {motSecret.Length} lettres"); + + while (vies > 0 && !motComplet) + { + // Afficher l'état actuel + Console.WriteLine($"\nVies restantes : {vies}"); + Console.WriteLine("Mot : " + string.Join(" ", lettresTrouvees)); + + // Demander une lettre + Console.Write("Propose une lettre : "); + var infoLettre = Console.ReadLine();//.KeyChar; + + var lettre = infoLettre[0]; + + // Vérifier si la lettre est dans le mot + bool lettreTrouvee = false; + for (int i = 0; i < motSecret.Length; i++) + { + if (motSecret[i] == lettre) + { + lettresTrouvees[i] = lettre; + lettreTrouvee = true; + } + } + + if (!lettreTrouvee) + { + vies--; + Console.WriteLine($"❌ La lettre '{lettre}' n'est pas dans le mot."); + } + else + { + Console.WriteLine($"✅ Bonne lettre !"); + } + + // Vérifier si le mot est complet + motComplet = true; + foreach (char c in lettresTrouvees) + { + if (c == '_') + { + motComplet = false; + break; + } + } + } + + // Résultat final + if (motComplet) + { + Console.WriteLine($"\n🎉 FÉLICITATIONS ! Tu as trouvé le mot : {motSecret}"); + } + else + { + Console.WriteLine($"\n💀 PERDU ! Le mot était : {motSecret}"); + } + + Console.WriteLine("\nAppuyez sur une touche pour quitter..."); + Console.ReadLine(); + } +} \ No newline at end of file diff --git a/MiniJeux/MiniJeux/Ppc.cs b/MiniJeux/MiniJeux/Ppc.cs new file mode 100644 index 0000000..e88bd59 --- /dev/null +++ b/MiniJeux/MiniJeux/Ppc.cs @@ -0,0 +1,64 @@ +public class Ppc +{ + private static readonly Dictionary Scores = new Dictionary() + { + {"joueur", 0}, + {"ordi", 0} + }; + + + + public Ppc() + { + Console.WriteLine("Bienvenue dans "); + Console.WriteLine("✊✋✌️ Pierre-Papier-Ciseaux !"); + Console.WriteLine("Premier à 3 points gagne !"); + Start(); + // Résultat final + Console.WriteLine($"\n{(Scores["joueur"] == 3 ? "🎉 TU AS GAGNÉ !" : "😢 L\'ordinateur a gagné...")}"); + Console.WriteLine($"Score final : {Scores["joueur"]} - {Scores["ordi"]}"); + } + + + + private static void Start() + { + var random = new Random(); + var choix_possibles = new[] { "pierre", "papier", "ciseaux" }; + + while (Scores["joueur"] < 3 && Scores["ordi"] < 3) + { + Console.WriteLine($"\nScore : Toi {Scores["joueur"]} - {Scores["ordi"]} Ordinateur"); + Console.WriteLine("Choisis (pierre, papier, ciseaux) : "); + var joueur = Console.ReadLine(); + + if (!choix_possibles.Contains(joueur?.ToLower())) + { + Console.WriteLine("❌ Choix invalide !"); + continue; + } + + + var ordi = random.GetItems(choix_possibles, 1).FirstOrDefault(); + Console.WriteLine($"🤖 L'ordinateur a choisi : {ordi}"); + + // Déterminer le gagnant + if (joueur == ordi) + { + Console.WriteLine("✨ Égalité !"); + } + else if ((joueur == "pierre" && ordi == "ciseaux") || + (joueur == "papier" && ordi == "pierre") || + (joueur == "ciseaux" && ordi == "papier")) + { + Console.WriteLine("✅ Tu gagnes cette manche !"); + Scores["joueur"] += 1; + } + else + { + Console.WriteLine("❌ L'ordinateur gagne cette manche !"); + Scores["ordi"] += 1; + } + } + } +} \ No newline at end of file diff --git a/MiniJeux/MiniJeux/Program.cs b/MiniJeux/MiniJeux/Program.cs new file mode 100644 index 0000000..3084c05 --- /dev/null +++ b/MiniJeux/MiniJeux/Program.cs @@ -0,0 +1,70 @@ +using System; +using System.Runtime.CompilerServices; + +class Program() +{ + private static readonly Dictionary Scores = new Dictionary() + { + {"joueur", 0}, + {"ordi", 0} + }; + + + + public static void Main() + { + // new Ppc(); + new Pendu(); + // Console.WriteLine("Bienvenue dans "); + // Console.WriteLine("✊✋✌️ Pierre-Papier-Ciseaux !"); + // Console.WriteLine("Premier à 3 points gagne !"); + // PierrePapierCiseaux(); + + // // Résultat final + // Console.WriteLine($"\n{(Scores["joueur"] == 3 ? "🎉 TU AS GAGNÉ !" : "😢 L\'ordinateur a gagné...")}"); + // Console.WriteLine($"Score final : {Scores["joueur"]} - {Scores["ordi"]}"); + } + + + + private static void PierrePapierCiseaux() + { + var random = new Random(); + var choix_possibles = new[] { "pierre", "papier", "ciseaux" }; + + while (Scores["joueur"] < 3 && Scores["ordi"] < 3) + { + Console.WriteLine($"\nScore : Toi {Scores["joueur"]} - {Scores["ordi"]} Ordinateur"); + Console.WriteLine("Choisis (pierre, papier, ciseaux) : "); + var joueur = Console.ReadLine(); + + if (!choix_possibles.Contains(joueur?.ToLower())) + { + Console.WriteLine("❌ Choix invalide !"); + continue; + } + + + var ordi = random.GetItems(choix_possibles, 1).FirstOrDefault(); + Console.WriteLine($"🤖 L'ordinateur a choisi : {ordi}"); + + // Déterminer le gagnant + if (joueur == ordi) + { + Console.WriteLine("✨ Égalité !"); + } + else if ((joueur == "pierre" && ordi == "ciseaux") || + (joueur == "papier" && ordi == "pierre") || + (joueur == "ciseaux" && ordi == "papier")) + { + Console.WriteLine("✅ Tu gagnes cette manche !"); + Scores["joueur"] += 1; + } + else + { + Console.WriteLine("❌ L'ordinateur gagne cette manche !"); + Scores["ordi"] += 1; + } + } + } +} diff --git a/MiniJeux/Tests/MiniJeux.Test/MiniJeux.Test.csproj b/MiniJeux/Tests/MiniJeux.Test/MiniJeux.Test.csproj new file mode 100644 index 0000000..94445b1 --- /dev/null +++ b/MiniJeux/Tests/MiniJeux.Test/MiniJeux.Test.csproj @@ -0,0 +1,25 @@ + + + + net9.0 + enable + enable + false + + + + + + + + + + + + + + + + + + diff --git a/MiniJeux/Tests/MiniJeux.Test/PpcTest.cs b/MiniJeux/Tests/MiniJeux.Test/PpcTest.cs new file mode 100644 index 0000000..6ca7b71 --- /dev/null +++ b/MiniJeux/Tests/MiniJeux.Test/PpcTest.cs @@ -0,0 +1,10 @@ +namespace MiniJeux.Test; + +public class PpcTest +{ + [Fact] + public void Test1() + { + + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..afff99c --- /dev/null +++ b/readme.md @@ -0,0 +1,17 @@ +# Découverte du Developpement + +1. Explication d un mini jeu "pierre, feuille, ciseaux" +2. Modification du mini jeu pour y intégrer des concepts de développement (refactoring, des tests (on va trouvé des bugs !) , des interfaces, des injections de dépendance, classe). +3. Ajout d un mini jeu "le pendu" (si il nous reste du temps) + + +# Prérequis + +`Fonctionne sur Win, unix, Mac` + +* [GitBash](https://git-scm.com/install/) +* [VsCode](https://code.visualstudio.com/download) +* [Sdk .net](https://dotnet.microsoft.com/fr-fr/download/dotnet/10.0) + * Les Extensions C# + * [.NET Install Tool](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.vscode-dotnet-runtime) + * [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) \ No newline at end of file