From bee0b21640b11ab023a3f32b4f6995feab41b765 Mon Sep 17 00:00:00 2001 From: damilareajisafe Date: Sat, 12 Sep 2026 17:58:39 +0100 Subject: [PATCH 1/2] Initial Commit --- MathGame.damilareajisafe/MathGame.damilareajisafe.slnx | 3 +++ .../MathGame.damilareajisafe.csproj | 10 ++++++++++ .../MathGame.damilareajisafe/Program.cs | 1 + 3 files changed, 14 insertions(+) create mode 100644 MathGame.damilareajisafe/MathGame.damilareajisafe.slnx create mode 100644 MathGame.damilareajisafe/MathGame.damilareajisafe/MathGame.damilareajisafe.csproj create mode 100644 MathGame.damilareajisafe/MathGame.damilareajisafe/Program.cs diff --git a/MathGame.damilareajisafe/MathGame.damilareajisafe.slnx b/MathGame.damilareajisafe/MathGame.damilareajisafe.slnx new file mode 100644 index 00000000..3b23f060 --- /dev/null +++ b/MathGame.damilareajisafe/MathGame.damilareajisafe.slnx @@ -0,0 +1,3 @@ + + + diff --git a/MathGame.damilareajisafe/MathGame.damilareajisafe/MathGame.damilareajisafe.csproj b/MathGame.damilareajisafe/MathGame.damilareajisafe/MathGame.damilareajisafe.csproj new file mode 100644 index 00000000..ed9781c2 --- /dev/null +++ b/MathGame.damilareajisafe/MathGame.damilareajisafe/MathGame.damilareajisafe.csproj @@ -0,0 +1,10 @@ + + + + Exe + net10.0 + enable + enable + + + diff --git a/MathGame.damilareajisafe/MathGame.damilareajisafe/Program.cs b/MathGame.damilareajisafe/MathGame.damilareajisafe/Program.cs new file mode 100644 index 00000000..1bc52a60 --- /dev/null +++ b/MathGame.damilareajisafe/MathGame.damilareajisafe/Program.cs @@ -0,0 +1 @@ +Console.WriteLine("Hello, World!"); From 1a1d14e1944306e03e1795738ed45f4a17b8db0c Mon Sep 17 00:00:00 2001 From: damilareajisafe Date: Sat, 12 Sep 2026 22:09:47 +0100 Subject: [PATCH 2/2] Project Complete! --- .../MathGame.damilareajisafe/Program.cs | 87 ++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/MathGame.damilareajisafe/MathGame.damilareajisafe/Program.cs b/MathGame.damilareajisafe/MathGame.damilareajisafe/Program.cs index 1bc52a60..8eef982b 100644 --- a/MathGame.damilareajisafe/MathGame.damilareajisafe/Program.cs +++ b/MathGame.damilareajisafe/MathGame.damilareajisafe/Program.cs @@ -1 +1,86 @@ -Console.WriteLine("Hello, World!"); +string answer; +int score = 0; +List gameHistory = new List(); + +List questions = new List(); +questions.Add(new string[] { "15 + 25", "40" }); +questions.Add(new string[] { "14 / 7", "2"}); +questions.Add(new string[] { "73 - 8", "65"}); +questions.Add(new string[] { "33 * 3", "99"}); +questions.Add(new string[] { "(3 * 4) / 12", "1"}); + + +while (true) +{ + Console.Clear(); + Console.WriteLine("WELCOME TO MATH GAME!"); + Console.WriteLine("To play, press 1\nTo view game history, press 2\nTo exit, press 3"); + string choice = Console.ReadLine(); + switch (choice) + { + case "1": + startGame(); + break; + case "2": + displayGameHistory(); + break; + case "3": + Console.Clear(); + Console.WriteLine("Goodbye!"); + Console.WriteLine("Press Enter to exit..."); + Console.ReadKey(); + return; + default: + Console.WriteLine("Invalid operation, try again!"); + restartMessage(); + continue; + } +} + +void startGame() +{ + foreach (string[] question in questions) + { + Console.Clear(); + Console.WriteLine($"{question[0]} = ?"); + answer = Console.ReadLine(); + if (answer == question[1]) score += 1; + } + + gameHistory.Add(score); + + Console.Clear(); + Console.WriteLine($"You scored {score} out of 5\n"); + score = 0; + Console.WriteLine("Game Over!\n"); + restartMessage(); +} + +void displayGameHistory() +{ + Console.Clear(); + if (gameHistory.Count() == 0) + { + Console.WriteLine("No game history to display!\nReturn after playing some games"); + restartMessage(); + } + else + { + for (int i = 0; i < gameHistory.Count(); i++) + { + Console.WriteLine($"Game {i + 1} Score: {gameHistory[i]}"); + } + Console.WriteLine("\n"); + restartMessage(); + } + +} + +void restartMessage() +{ + Console.WriteLine("Press any key to continue..."); + Console.ReadKey(); +} + + +