From 9b1582085927c4f9939bd9c13e876370fa7dc140 Mon Sep 17 00:00:00 2001 From: Keith Edwards <89081584+kedwards1306@users.noreply.github.com> Date: Mon, 12 Jan 2026 20:17:13 -0500 Subject: [PATCH 1/5] Project Finished --- MathGame | 1 + 1 file changed, 1 insertion(+) create mode 160000 MathGame diff --git a/MathGame b/MathGame new file mode 160000 index 00000000..a634d0bf --- /dev/null +++ b/MathGame @@ -0,0 +1 @@ +Subproject commit a634d0bffb3e615877e6f3494b2920e168b1cbc3 From 257e0922bfa4c57d63c28b331aaaf4f132decc0f Mon Sep 17 00:00:00 2001 From: Keith Edwards <89081584+kedwards1306@users.noreply.github.com> Date: Mon, 19 Jan 2026 10:55:43 -0500 Subject: [PATCH 2/5] Deleted the git folder --- MathGame | 1 - kedwards.MathGame/MathGame.csproj | 10 ++ kedwards.MathGame/Program.cs | 205 ++++++++++++++++++++++++++++++ 3 files changed, 215 insertions(+), 1 deletion(-) delete mode 160000 MathGame create mode 100644 kedwards.MathGame/MathGame.csproj create mode 100644 kedwards.MathGame/Program.cs diff --git a/MathGame b/MathGame deleted file mode 160000 index a634d0bf..00000000 --- a/MathGame +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a634d0bffb3e615877e6f3494b2920e168b1cbc3 diff --git a/kedwards.MathGame/MathGame.csproj b/kedwards.MathGame/MathGame.csproj new file mode 100644 index 00000000..ed9781c2 --- /dev/null +++ b/kedwards.MathGame/MathGame.csproj @@ -0,0 +1,10 @@ + + + + Exe + net10.0 + enable + enable + + + diff --git a/kedwards.MathGame/Program.cs b/kedwards.MathGame/Program.cs new file mode 100644 index 00000000..8e784da9 --- /dev/null +++ b/kedwards.MathGame/Program.cs @@ -0,0 +1,205 @@ +// See https://aka.ms/new-console-template for more information +using System.Diagnostics; + + +// int add = 0; +// int substract = 0; +// int multiply = 0; +// int division = 0; +List pastScores = new List(); +bool playAgain = true; + +while(playAgain) +{ + Menu(); + string choice = UserChoices(); + Questions(choice); + Console.WriteLine("Do you want to play again? (y/n)"); + string answer = Console.ReadLine().Trim().ToLower(); + + if (answer != "y") + { + playAgain = false; + Console.WriteLine("Thanks for playing!"); + } +} +void Menu() { + Console.WriteLine("------------------------------------"); + Console.WriteLine("Hello, Welcome to the Math Game!"); + Console.WriteLine("What is your name?"); + string userName = Console.ReadLine(); + Console.WriteLine($"Hello {userName}, let's start the game!"); + Console.WriteLine("Please choose your choices"); + +} + +string UserChoices() +{ + Console.WriteLine("Choose an operation:"); + Console.WriteLine("1. Addition"); + Console.WriteLine("2. Subtraction"); + Console.WriteLine("3. Multiplication"); + Console.WriteLine("4. Division"); + + string choice = Console.ReadLine(); + + + if (choice.Trim() == "1") + { + Addition(); + } + else if (choice.Trim() == "2") + { + Subtraction(); + } + else if (choice.Trim() == "3") + { + Multiplication(); + } + else if (choice.Trim() == "4") + { + Division(); + } + else if (choice.Trim().ToLower() == "q") + { + Console.WriteLine("Goodbye"); + Environment.Exit(0); + } + else + { + Console.WriteLine(" Invalid Choice"); + } + return choice; +} +//creating Choices in switch break cases +// selection 1. - Addition so userInput1 + userInput2 +// selection 2. - Subtraction so userInput1 - userInput2 +// selection 3. - Multiplication so userInput1 * userInput2 +// selection 4. - Division so userInput1 / userInput2 + +void Questions(string questions) +{ + Random random = new Random(); + int score = 0; + int timeLimitSeconds = 10; + for (int i = 0; i < 5; i ++) + { + int num1 = random.Next(1, 10); + int num2 = random.Next(1, 10); + int correctAnswer = 0; + switch (questions) + { + case "1": + Console.WriteLine($"What is {num1} + {num2}? "); + correctAnswer = num1 + num2; + break; + case "2": + Console.WriteLine($"What is {num1} - {num2}? "); + correctAnswer = num1 - num2; + break; + case "3": + Console.WriteLine($"What is {num1} x {num2}? "); + correctAnswer = num1 * num2; + break; + case "4": + while (num2 == 0) + { + num2 = random.Next(1, 10); + } + correctAnswer = num1 / num2; + Console.WriteLine($"What is {num1} / {num2}? "); + break; + + case "q": + Console.WriteLine("Goodbye"); + Environment.Exit(1); + break; + default: + Console.WriteLine("Invalid choice"); + Environment.Exit(1); + break; + } + bool timeUp = false; + //Timer Thread + Stopwatch stopwatch = Stopwatch.StartNew(); + string input = Console.ReadLine(); + Thread timerThread = new Thread(() => + { + for (int t = timeLimitSeconds; t > 0; t--) + { + if (stopwatch.Elapsed.TotalSeconds >= timeLimitSeconds) + { + Console.WriteLine("Time's up!"); + Console.WriteLine($"The correct answer was {correctAnswer}"); + continue; + } + + Thread.Sleep(1000); + } + }); + timerThread.Start(); + // timerThread.Join(); + stopwatch.Stop(); + + int userResult; + bool validInput = int.TryParse(input, out userResult); + if (validInput && userResult == correctAnswer) + { + Console.WriteLine("Your answer is correct"); + score++; + + } + else + { + Console.WriteLine($"Your answer is incorrect! The answer is {correctAnswer}"); + } + + } + pastScores.Add(score); + Console.WriteLine($"Game Over! the final scoreis {score} / 5"); + ShowPastScore(); + +} +void Addition() +{ + Console.WriteLine(" Addition Selected"); +} +void Subtraction() +{ + Console.WriteLine(" Subtraction Selected"); +} +void Multiplication() +{ + Console.WriteLine(" Multiplication Selected"); +} +void Division() +{ + Console.WriteLine(" Division Selected"); +} + +void ShowPastScore() +{ + bool seeScore = true; + while (seeScore) + { + Console.WriteLine("Do you want to see your past scores? (y/n)"); + string input = Console.ReadLine(); + if (input == "y") + { + Console.WriteLine("\n Past Scores:"); + for (int i = 0; i < pastScores.Count; i++) + { + Console.WriteLine($"Game {i + 1}: {pastScores[i]} / 5"); + } + } + else if (input == "n") + { + seeScore = false; + return; + } + else + { + Console.WriteLine("Invalid input"); + } + } +} From cdd13f9be2ae8f3706bc8866066361ad9a6b80cb Mon Sep 17 00:00:00 2001 From: Keith Edwards <89081584+kedwards1306@users.noreply.github.com> Date: Mon, 19 Jan 2026 11:04:42 -0500 Subject: [PATCH 3/5] Updated minor issues with codacy --- kedwards.MathGame/Program.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/kedwards.MathGame/Program.cs b/kedwards.MathGame/Program.cs index 8e784da9..5ad3e253 100644 --- a/kedwards.MathGame/Program.cs +++ b/kedwards.MathGame/Program.cs @@ -1,11 +1,6 @@ // See https://aka.ms/new-console-template for more information using System.Diagnostics; - -// int add = 0; -// int substract = 0; -// int multiply = 0; -// int division = 0; List pastScores = new List(); bool playAgain = true; @@ -77,7 +72,7 @@ string UserChoices() // selection 3. - Multiplication so userInput1 * userInput2 // selection 4. - Division so userInput1 / userInput2 -void Questions(string questions) +void Questions(string question) { Random random = new Random(); int score = 0; @@ -87,7 +82,7 @@ void Questions(string questions) int num1 = random.Next(1, 10); int num2 = random.Next(1, 10); int correctAnswer = 0; - switch (questions) + switch (question) { case "1": Console.WriteLine($"What is {num1} + {num2}? "); @@ -119,7 +114,7 @@ void Questions(string questions) Environment.Exit(1); break; } - bool timeUp = false; + //Timer Thread Stopwatch stopwatch = Stopwatch.StartNew(); string input = Console.ReadLine(); @@ -138,7 +133,7 @@ void Questions(string questions) } }); timerThread.Start(); - // timerThread.Join(); + stopwatch.Stop(); int userResult; From cc8e5b59c90ba8c3383fbc711c7fffec6de9ba3c Mon Sep 17 00:00:00 2001 From: Keith Edwards <89081584+kedwards1306@users.noreply.github.com> Date: Sat, 24 Jan 2026 11:12:42 -0500 Subject: [PATCH 4/5] Made correction to integer and to show PastScore in the menu --- kedwards.MathGame/Program.cs | 51 ++++++++++++------------------------ 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/kedwards.MathGame/Program.cs b/kedwards.MathGame/Program.cs index 5ad3e253..08bd82d9 100644 --- a/kedwards.MathGame/Program.cs +++ b/kedwards.MathGame/Program.cs @@ -8,6 +8,10 @@ { Menu(); string choice = UserChoices(); + if (choice == "5") + { + continue; + } Questions(choice); Console.WriteLine("Do you want to play again? (y/n)"); string answer = Console.ReadLine().Trim().ToLower(); @@ -37,7 +41,7 @@ string UserChoices() Console.WriteLine("4. Division"); string choice = Console.ReadLine(); - + if (choice.Trim() == "1") { @@ -55,6 +59,11 @@ string UserChoices() { Division(); } + + else if (choice.Trim() == "5") + { + ShowPastScore(); + } else if (choice.Trim().ToLower() == "q") { Console.WriteLine("Goodbye"); @@ -117,32 +126,19 @@ void Questions(string question) //Timer Thread Stopwatch stopwatch = Stopwatch.StartNew(); - string input = Console.ReadLine(); - Thread timerThread = new Thread(() => - { - for (int t = timeLimitSeconds; t > 0; t--) - { - if (stopwatch.Elapsed.TotalSeconds >= timeLimitSeconds) - { - Console.WriteLine("Time's up!"); - Console.WriteLine($"The correct answer was {correctAnswer}"); - continue; - } - - Thread.Sleep(1000); - } - }); - timerThread.Start(); - - stopwatch.Stop(); - + string input = Console.ReadLine(); + stopwatch.Stop(); + if (stopwatch.Elapsed.TotalSeconds > timeLimitSeconds) + { + Console.WriteLine("Time's up!"); + Console.WriteLine($"The correct answer was {correctAnswer}"); + } int userResult; bool validInput = int.TryParse(input, out userResult); if (validInput && userResult == correctAnswer) { Console.WriteLine("Your answer is correct"); score++; - } else { @@ -174,9 +170,6 @@ void Division() void ShowPastScore() { - bool seeScore = true; - while (seeScore) - { Console.WriteLine("Do you want to see your past scores? (y/n)"); string input = Console.ReadLine(); if (input == "y") @@ -187,14 +180,4 @@ void ShowPastScore() Console.WriteLine($"Game {i + 1}: {pastScores[i]} / 5"); } } - else if (input == "n") - { - seeScore = false; - return; - } - else - { - Console.WriteLine("Invalid input"); - } - } } From 0fba94a2a06d799db0a7f464f1aab88209600625 Mon Sep 17 00:00:00 2001 From: Keith Edwards <89081584+kedwards1306@users.noreply.github.com> Date: Sat, 24 Jan 2026 11:16:35 -0500 Subject: [PATCH 5/5] Add PastScores in the menu --- kedwards.MathGame/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/kedwards.MathGame/Program.cs b/kedwards.MathGame/Program.cs index 08bd82d9..c89a3a54 100644 --- a/kedwards.MathGame/Program.cs +++ b/kedwards.MathGame/Program.cs @@ -39,6 +39,7 @@ string UserChoices() Console.WriteLine("2. Subtraction"); Console.WriteLine("3. Multiplication"); Console.WriteLine("4. Division"); + Console.WriteLine("5. ShowPastScores"); string choice = Console.ReadLine();