From d0ee97e7e8a0b35738366b5250ba98fffa2ab075 Mon Sep 17 00:00:00 2001 From: samphillips997 <15917578+samphillips997@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:30:59 -0700 Subject: [PATCH 1/5] Initial commit --- MathGame/MathGame.slnx | 3 +++ MathGame/MathGame/MathGame.csproj | 10 ++++++++++ MathGame/MathGame/Program.cs | 1 + 3 files changed, 14 insertions(+) create mode 100644 MathGame/MathGame.slnx create mode 100644 MathGame/MathGame/MathGame.csproj create mode 100644 MathGame/MathGame/Program.cs diff --git a/MathGame/MathGame.slnx b/MathGame/MathGame.slnx new file mode 100644 index 00000000..c91187ad --- /dev/null +++ b/MathGame/MathGame.slnx @@ -0,0 +1,3 @@ + + + diff --git a/MathGame/MathGame/MathGame.csproj b/MathGame/MathGame/MathGame.csproj new file mode 100644 index 00000000..ed9781c2 --- /dev/null +++ b/MathGame/MathGame/MathGame.csproj @@ -0,0 +1,10 @@ + + + + Exe + net10.0 + enable + enable + + + diff --git a/MathGame/MathGame/Program.cs b/MathGame/MathGame/Program.cs new file mode 100644 index 00000000..1bc52a60 --- /dev/null +++ b/MathGame/MathGame/Program.cs @@ -0,0 +1 @@ +Console.WriteLine("Hello, World!"); From 49d6346976d494b2a253f3bcff18b9643624e460 Mon Sep 17 00:00:00 2001 From: samphillips997 <15917578+samphillips997@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:35:06 -0700 Subject: [PATCH 2/5] Test commit --- MathGame/MathGame/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MathGame/MathGame/Program.cs b/MathGame/MathGame/Program.cs index 1bc52a60..13b25e4f 100644 --- a/MathGame/MathGame/Program.cs +++ b/MathGame/MathGame/Program.cs @@ -1 +1 @@ -Console.WriteLine("Hello, World!"); +Console.WriteLine("Test"); From 18cb1dc4f616dc3db466fe6ec09cc02b2c5fac2b Mon Sep 17 00:00:00 2001 From: samphillips997 <15917578+samphillips997@users.noreply.github.com> Date: Thu, 26 Mar 2026 20:06:36 -0700 Subject: [PATCH 3/5] Add initial game logic --- MathGame/MathGame/Program.cs | 62 +++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/MathGame/MathGame/Program.cs b/MathGame/MathGame/Program.cs index 13b25e4f..5bf16dff 100644 --- a/MathGame/MathGame/Program.cs +++ b/MathGame/MathGame/Program.cs @@ -1 +1,61 @@ -Console.WriteLine("Test"); +while (true) +{ + showMainMenu(); + + string menuSelection = Console.ReadLine(); + + if (menuSelection == "1") + { + int result = playGame(); + Console.WriteLine($"You got {result} / 5 correct!"); + } + else if (menuSelection == "2") + { + // TODO + } + else if (menuSelection == "x") + { + break; + } + else + { + Console.WriteLine("Incorrect menu selection. Please try again."); + } +} + + + +void showMainMenu() +{ + Console.WriteLine("Main Menu"); + Console.WriteLine("1. Play Math Game!"); + Console.WriteLine("2. Show Scores"); + Console.WriteLine("Enter x to exit"); +} + +int playGame() +{ + string[] questions = ["9 x 9", "5 + 3", "6 - 2", "8 / 4", "7 * 5"]; + int[] answers = [81, 8, 4, 2, 35]; + + int correct = 0; + + // Gets input from user and increments correct if it matches the answer + for (int i = 0; i < questions.Length; i++) + { + Console.Write($"What does {questions[i]} = "); + int userInput = int.Parse(Console.ReadLine()); + + if (userInput == answers[i]) + { + Console.WriteLine("Correct!"); + correct++; + } + else + { + Console.WriteLine("Incorrect :("); + } + } + + return correct; +} \ No newline at end of file From e9b389d24c881e4802e944ee8df8dc8e533d7e65 Mon Sep 17 00:00:00 2001 From: Sam Phillips <15917578+samphillips997@users.noreply.github.com> Date: Fri, 27 Mar 2026 08:38:14 -0700 Subject: [PATCH 4/5] Refactoring, collect & show past games --- MathGame/MathGame/Program.cs | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/MathGame/MathGame/Program.cs b/MathGame/MathGame/Program.cs index 5bf16dff..93fe85bf 100644 --- a/MathGame/MathGame/Program.cs +++ b/MathGame/MathGame/Program.cs @@ -1,4 +1,10 @@ -while (true) +using System.Collections.Generic; + +string[] questions = ["9 x 9", "5 + 3", "6 - 2", "8 / 4", "7 * 5"]; +int[] answers = [81, 8, 4, 2, 35]; +List pastGames = new List(); + +while (true) { showMainMenu(); @@ -6,12 +12,14 @@ if (menuSelection == "1") { - int result = playGame(); - Console.WriteLine($"You got {result} / 5 correct!"); + int result = playGame(questions, answers); + Console.WriteLine($"You got {result} / {questions.Length} correct!"); + + pastGames.Add($"{result} / {questions.Length} - {((decimal)result / questions.Length):P0}"); } else if (menuSelection == "2") { - // TODO + printPastGames(pastGames); } else if (menuSelection == "x") { @@ -33,14 +41,11 @@ void showMainMenu() Console.WriteLine("Enter x to exit"); } -int playGame() +// Gets input from user and increments correct if it matches the answer +int playGame(string[] questions, int[] answers) { - string[] questions = ["9 x 9", "5 + 3", "6 - 2", "8 / 4", "7 * 5"]; - int[] answers = [81, 8, 4, 2, 35]; - int correct = 0; - - // Gets input from user and increments correct if it matches the answer + for (int i = 0; i < questions.Length; i++) { Console.Write($"What does {questions[i]} = "); @@ -56,6 +61,15 @@ int playGame() Console.WriteLine("Incorrect :("); } } - + return correct; +} + +void printPastGames(List games) +{ + Console.WriteLine("Past Games:"); + foreach (string game in games) + { + Console.WriteLine(game); + } } \ No newline at end of file From 469a625af393ed2f531ec804bca6601d1e4d4713 Mon Sep 17 00:00:00 2001 From: Sam Phillips <15917578+samphillips997@users.noreply.github.com> Date: Fri, 27 Mar 2026 08:40:09 -0700 Subject: [PATCH 5/5] Update function names --- MathGame/MathGame/Program.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MathGame/MathGame/Program.cs b/MathGame/MathGame/Program.cs index 93fe85bf..d236eb4b 100644 --- a/MathGame/MathGame/Program.cs +++ b/MathGame/MathGame/Program.cs @@ -6,20 +6,20 @@ while (true) { - showMainMenu(); + ShowMainMenu(); string menuSelection = Console.ReadLine(); if (menuSelection == "1") { - int result = playGame(questions, answers); + int result = PlayGame(questions, answers); Console.WriteLine($"You got {result} / {questions.Length} correct!"); pastGames.Add($"{result} / {questions.Length} - {((decimal)result / questions.Length):P0}"); } else if (menuSelection == "2") { - printPastGames(pastGames); + PrintPastGames(pastGames); } else if (menuSelection == "x") { @@ -33,7 +33,7 @@ -void showMainMenu() +void ShowMainMenu() { Console.WriteLine("Main Menu"); Console.WriteLine("1. Play Math Game!"); @@ -42,7 +42,7 @@ void showMainMenu() } // Gets input from user and increments correct if it matches the answer -int playGame(string[] questions, int[] answers) +int PlayGame(string[] questions, int[] answers) { int correct = 0; @@ -65,7 +65,7 @@ int playGame(string[] questions, int[] answers) return correct; } -void printPastGames(List games) +void PrintPastGames(List games) { Console.WriteLine("Past Games:"); foreach (string game in games)