correction
This commit is contained in:
@@ -2,65 +2,65 @@
|
|||||||
{
|
{
|
||||||
internal class Ppc0
|
internal class Ppc0
|
||||||
{
|
{
|
||||||
private static Dictionary<string, int> _scores;
|
//private static Dictionary<string, int> _scores;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void Main()
|
//public static void Main()
|
||||||
{
|
//{
|
||||||
Console.WriteLine("Bienvenue dans ");
|
// Console.WriteLine("Bienvenue dans ");
|
||||||
Console.WriteLine("✊✋✌️ Pierre-Papier-Ciseaux !");
|
// Console.WriteLine("✊✋✌️ Pierre-Papier-Ciseaux !");
|
||||||
Console.WriteLine("Premier à 3 points gagne !");
|
// Console.WriteLine("Premier à 3 points gagne !");
|
||||||
PierrePapierCiseaux();
|
// PierrePapierCiseaux();
|
||||||
// Résultat final
|
// // Résultat final
|
||||||
Console.WriteLine($"\n{(_scores["joueur"] == 3 ? "🎉 TU AS GAGNÉ !" : "😢 L\'ordinateur a gagné...")}");
|
// Console.WriteLine($"\n{(_scores["joueur"] == 3 ? "🎉 TU AS GAGNÉ !" : "😢 L\'ordinateur a gagné...")}");
|
||||||
Console.WriteLine($"Score final : {_scores["joueur"]} - {_scores["ordi"]}");
|
// Console.WriteLine($"Score final : {_scores["joueur"]} - {_scores["ordi"]}");
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void PierrePapierCiseaux()
|
//private static void PierrePapierCiseaux()
|
||||||
{
|
//{
|
||||||
var random = new Random();
|
// var random = new Random();
|
||||||
var choix_possibles = new[] { "pierre", "papier", "ciseaux" };
|
// var choix_possibles = new[] { "pierre", "papier", "ciseaux" };
|
||||||
_scores = new Dictionary<string, int>()
|
// _scores = new Dictionary<string, int>()
|
||||||
{
|
// {
|
||||||
{"joueur", 0},
|
// {"joueur", 0},
|
||||||
{"ordi", 0}
|
// {"ordi", 0}
|
||||||
};
|
// };
|
||||||
|
|
||||||
// On boucle à jusqu'a que le joueur ou l'utilisateur arrive à 3.
|
// // On boucle à jusqu'a que le joueur ou l'utilisateur arrive à 3.
|
||||||
while (_scores["joueur"] < 3 && _scores["ordi"] < 3)
|
// while (_scores["joueur"] < 3 && _scores["ordi"] < 3)
|
||||||
{
|
// {
|
||||||
Console.WriteLine($"\nScore : Toi {_scores["joueur"]} - {_scores["ordi"]} Ordinateur");
|
// Console.WriteLine($"\nScore : Toi {_scores["joueur"]} - {_scores["ordi"]} Ordinateur");
|
||||||
Console.WriteLine("Choisis (pierre, papier, ciseaux) : ");
|
// Console.WriteLine("Choisis (pierre, papier, ciseaux) : ");
|
||||||
var joueur = Console.ReadLine().ToLower();
|
// var joueur = Console.ReadLine().ToLower();
|
||||||
if (!choix_possibles.Contains(joueur))
|
// if (!choix_possibles.Contains(joueur))
|
||||||
{
|
// {
|
||||||
Console.WriteLine("❌ Choix invalide !");
|
// Console.WriteLine("❌ Choix invalide !");
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var ordi = random.GetItems(choix_possibles, 1).FirstOrDefault();
|
// var ordi = random.GetItems(choix_possibles, 1).FirstOrDefault();
|
||||||
Console.WriteLine($"🤖 L'ordinateur a choisi : {ordi}");
|
// Console.WriteLine($"🤖 L'ordinateur a choisi : {ordi}");
|
||||||
// Déterminer le gagnant
|
// // Déterminer le gagnant
|
||||||
if (joueur == ordi)
|
// if (joueur == ordi)
|
||||||
{
|
// {
|
||||||
Console.WriteLine("✨ Égalité !");
|
// Console.WriteLine("✨ Égalité !");
|
||||||
}
|
// }
|
||||||
else if ((joueur == "pierre" && ordi == "ciseaux") ||
|
// else if ((joueur == "pierre" && ordi == "ciseaux") ||
|
||||||
(joueur == "papier" && ordi == "pierre") ||
|
// (joueur == "papier" && ordi == "pierre") ||
|
||||||
(joueur == "ciseaux" && ordi == "papier"))
|
// (joueur == "ciseaux" && ordi == "papier"))
|
||||||
{
|
// {
|
||||||
Console.WriteLine("✅ Tu gagnes cette manche !");
|
// Console.WriteLine("✅ Tu gagnes cette manche !");
|
||||||
_scores["joueur"] += 1;
|
// _scores["joueur"] += 1;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
Console.WriteLine("❌ L'ordinateur gagne cette manche !");
|
// Console.WriteLine("❌ L'ordinateur gagne cette manche !");
|
||||||
_scores["ordi"] += 1;
|
// _scores["ordi"] += 1;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,37 @@ class Program()
|
|||||||
var game = PierrePapierCiseauxGameFactory.CreateGame(consoleService);
|
var game = PierrePapierCiseauxGameFactory.CreateGame(consoleService);
|
||||||
var runner = new GameRunnerConsole(consoleService, game);
|
var runner = new GameRunnerConsole(consoleService, game);
|
||||||
runner.Run();
|
runner.Run();
|
||||||
|
|
||||||
|
var personne = new Personne("toto");
|
||||||
|
personne.ShowName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Personne
|
||||||
|
{
|
||||||
|
|
||||||
|
public Personne(string name)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
public string GetFirstLetter()
|
||||||
|
{
|
||||||
|
return Name.FirstOrDefault().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowName()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Votre nom est: " + Plop());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private string Plop()
|
||||||
|
{
|
||||||
|
return Name[0].ToString().ToUpper() + Name[1..];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user