From 363a216a9e8b8543e994b1c6d3a4a737a6a6640f Mon Sep 17 00:00:00 2001 From: Sean Lynch <66145294+MacroScenery@users.noreply.github.com> Date: Sun, 15 May 2022 10:34:23 -0400 Subject: [PATCH] fixed double input bug --- 93_23_Matches/csharp/23Matches.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/93_23_Matches/csharp/23Matches.cs b/93_23_Matches/csharp/23Matches.cs index 28f3d3bb..8a839d23 100644 --- a/93_23_Matches/csharp/23Matches.cs +++ b/93_23_Matches/csharp/23Matches.cs @@ -7,6 +7,7 @@ namespace Program public static int numberOfMatches; public static int numberOfMatchesRemovedByPlayer; + public static bool playerGoesFirst = false; static void Main(string[] args) { // Print introduction text @@ -41,6 +42,7 @@ namespace Program if (coinTossResult == 1) { Console.WriteLine("TAILS! YOU GO FIRST. "); + playerGoesFirst = true; PlayerTurn(); } else @@ -54,8 +56,12 @@ namespace Program do { - Console.Write("THE NUMBER OF MATCHES IS NOW " + numberOfMatches); - PlayerTurn(); + if (playerGoesFirst == false) + { + Console.Write("THE NUMBER OF MATCHES IS NOW " + numberOfMatches); + PlayerTurn(); + } + playerGoesFirst = false; ComputerTurn(); } while (numberOfMatches > 1);