From 0df89a35ab77e49d0f9bd21dab0c68aa7c9d3767 Mon Sep 17 00:00:00 2001 From: Tetris Date: Sat, 22 Aug 2026 23:15:33 +0200 Subject: [PATCH 1/5] Project init --- MathGame.tetris_y/MathGame.tetris_y.slnx | 3 +++ .../MathGame.tetris_y/MathGame.tetris_y.csproj | 10 ++++++++++ MathGame.tetris_y/MathGame.tetris_y/Menu.cs | 10 ++++++++++ MathGame.tetris_y/MathGame.tetris_y/Program.cs | 4 ++++ 4 files changed, 27 insertions(+) create mode 100644 MathGame.tetris_y/MathGame.tetris_y.slnx create mode 100644 MathGame.tetris_y/MathGame.tetris_y/MathGame.tetris_y.csproj create mode 100644 MathGame.tetris_y/MathGame.tetris_y/Menu.cs create mode 100644 MathGame.tetris_y/MathGame.tetris_y/Program.cs diff --git a/MathGame.tetris_y/MathGame.tetris_y.slnx b/MathGame.tetris_y/MathGame.tetris_y.slnx new file mode 100644 index 00000000..39cdfa66 --- /dev/null +++ b/MathGame.tetris_y/MathGame.tetris_y.slnx @@ -0,0 +1,3 @@ + + + diff --git a/MathGame.tetris_y/MathGame.tetris_y/MathGame.tetris_y.csproj b/MathGame.tetris_y/MathGame.tetris_y/MathGame.tetris_y.csproj new file mode 100644 index 00000000..ed9781c2 --- /dev/null +++ b/MathGame.tetris_y/MathGame.tetris_y/MathGame.tetris_y.csproj @@ -0,0 +1,10 @@ + + + + Exe + net10.0 + enable + enable + + + diff --git a/MathGame.tetris_y/MathGame.tetris_y/Menu.cs b/MathGame.tetris_y/MathGame.tetris_y/Menu.cs new file mode 100644 index 00000000..98138fb8 --- /dev/null +++ b/MathGame.tetris_y/MathGame.tetris_y/Menu.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace MathGame.tetris_y +{ + internal class Menu + { + } +} diff --git a/MathGame.tetris_y/MathGame.tetris_y/Program.cs b/MathGame.tetris_y/MathGame.tetris_y/Program.cs new file mode 100644 index 00000000..2dd36b6b --- /dev/null +++ b/MathGame.tetris_y/MathGame.tetris_y/Program.cs @@ -0,0 +1,4 @@ +class Program +{ + +} \ No newline at end of file From 7c76152689f83444136c35381a9c7286931119c8 Mon Sep 17 00:00:00 2001 From: Tetris Date: Sat, 22 Aug 2026 23:18:42 +0200 Subject: [PATCH 2/5] Add main menu --- MathGame.tetris_y/MathGame.tetris_y/Program.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MathGame.tetris_y/MathGame.tetris_y/Program.cs b/MathGame.tetris_y/MathGame.tetris_y/Program.cs index 2dd36b6b..8fa91a5f 100644 --- a/MathGame.tetris_y/MathGame.tetris_y/Program.cs +++ b/MathGame.tetris_y/MathGame.tetris_y/Program.cs @@ -1,4 +1,12 @@ -class Program +while (true) { + Console.WriteLine("===== Welcome to the Math Game! ====="); + Console.WriteLine("1. Addition"); + Console.WriteLine("2. Subtraction"); + Console.WriteLine("3. Multiplication"); + Console.WriteLine("4. Division"); + Console.WriteLine("5. Exit"); + Console.Write("Enter your choice (1-5):"); + int choice = Convert.ToInt32(Console.ReadLine()); } \ No newline at end of file From dc9115472b83e137c5a2de70e8c094d591f0bec2 Mon Sep 17 00:00:00 2001 From: Tetris Date: Sat, 22 Aug 2026 23:23:34 +0200 Subject: [PATCH 3/5] Add switch to let user choose option --- .../MathGame.tetris_y/Program.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/MathGame.tetris_y/MathGame.tetris_y/Program.cs b/MathGame.tetris_y/MathGame.tetris_y/Program.cs index 8fa91a5f..373aaf15 100644 --- a/MathGame.tetris_y/MathGame.tetris_y/Program.cs +++ b/MathGame.tetris_y/MathGame.tetris_y/Program.cs @@ -9,4 +9,30 @@ Console.Write("Enter your choice (1-5):"); int choice = Convert.ToInt32(Console.ReadLine()); + + switch (choice) + { + case 1: + //PerformAddition(); + break; + case 2: + //PerformSubtraction(); + break; + case 3: + //PerformMultiplication(); + break; + case 4: + //PerformDivision(); + break; + case 5: + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("Thank you for playing! Goodbye!\n"); + Console.ResetColor(); + return; + default: + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Invalid choice. Please try again.\n"); + Console.ResetColor(); + break; + } } \ No newline at end of file From 765ae43311f4605ed48a8e407af1d79724561f24 Mon Sep 17 00:00:00 2001 From: Tetris Date: Sun, 23 Aug 2026 14:56:07 +0200 Subject: [PATCH 4/5] Add function to perform all operations --- .../MathGame.tetris_y/Program.cs | 143 ++++++++++++++---- 1 file changed, 111 insertions(+), 32 deletions(-) diff --git a/MathGame.tetris_y/MathGame.tetris_y/Program.cs b/MathGame.tetris_y/MathGame.tetris_y/Program.cs index 373aaf15..cf946b38 100644 --- a/MathGame.tetris_y/MathGame.tetris_y/Program.cs +++ b/MathGame.tetris_y/MathGame.tetris_y/Program.cs @@ -1,38 +1,117 @@ -while (true) +using System; +using System.Runtime.Intrinsics.Arm; + +class Program { - Console.WriteLine("===== Welcome to the Math Game! ====="); - Console.WriteLine("1. Addition"); - Console.WriteLine("2. Subtraction"); - Console.WriteLine("3. Multiplication"); - Console.WriteLine("4. Division"); - Console.WriteLine("5. Exit"); + static void Main(string[] args) + { + while (true) + { + Console.WriteLine("===== Welcome to the Math Game! ====="); + Console.WriteLine("1. Addition"); + Console.WriteLine("2. Subtraction"); + Console.WriteLine("3. Multiplication"); + Console.WriteLine("4. Division"); + Console.WriteLine("5. Exit"); + + Console.Write("Enter your choice (1-5):"); + int choice = Convert.ToInt32(Console.ReadLine()); - Console.Write("Enter your choice (1-5):"); - int choice = Convert.ToInt32(Console.ReadLine()); + switch (choice) + { + case 1: + Console.Clear(); + PerformCalculation(1); + break; + case 2: + PerformCalculation(2); + break; + case 3: + PerformCalculation(3); + break; + case 4: + PerformCalculation(4); + break; + case 5: + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("Thank you for playing! Goodbye!\n"); + Console.ResetColor(); + return; + default: + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Invalid choice. Please try again.\n"); + Console.ResetColor(); + break; + } + } + } - switch (choice) + static void PerformCalculation(int operation) { - case 1: - //PerformAddition(); - break; - case 2: - //PerformSubtraction(); - break; - case 3: - //PerformMultiplication(); - break; - case 4: - //PerformDivision(); - break; - case 5: - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine("Thank you for playing! Goodbye!\n"); - Console.ResetColor(); - return; - default: - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("Invalid choice. Please try again.\n"); - Console.ResetColor(); - break; + Random random = new Random(); + + for (int i = 0; i < 5; i++) + { + int num1, num2; + int correctAnswer = 0; + + switch (operation) + { + case 1: + num1 = random.Next(1, 101); + num2 = random.Next(1, 101); + correctAnswer = num1 + num2; + Console.Write($"What is {num1} + {num2}?: "); + break; + case 2: + num1 = random.Next(1, 101); + num2 = random.Next(1, 101); + correctAnswer = num1 - num2; + Console.Write($"What is {num1} - {num2}?: "); + break; + case 3: + num1 = random.Next(1, 101); + num2 = random.Next(1, 101); + correctAnswer = num1 * num2; + Console.Write($"What is {num1} * {num2}?: "); + break; + case 4: + do + { + num1 = random.Next(1, 101); + num2 = random.Next(1, 101); + } while (num1 % num2 != 0); + correctAnswer = num1 / num2; + Console.Write($"What is {num1} / {num2}?: "); + break; + } + + + int userAnswer = Convert.ToInt32(Console.ReadLine()); + if (userAnswer == correctAnswer) + { + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("Correct!\n"); + Console.ResetColor(); + } + else + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"Incorrect. The correct answer is {correctAnswer}.\n"); + Console.ResetColor(); + } + } + } + + static bool checkDivisonResult(int num1, int num2) + { + if (num1 % num2 == 0) + { + return true; + } else + { + return false; + } + } } \ No newline at end of file From 03ce9a7f57fda50165430fee48f44adf1738e01a Mon Sep 17 00:00:00 2001 From: Tetris Date: Sun, 23 Aug 2026 15:18:02 +0200 Subject: [PATCH 5/5] Add game history --- .../MathGame.tetris_y/Program.cs | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/MathGame.tetris_y/MathGame.tetris_y/Program.cs b/MathGame.tetris_y/MathGame.tetris_y/Program.cs index cf946b38..7260796c 100644 --- a/MathGame.tetris_y/MathGame.tetris_y/Program.cs +++ b/MathGame.tetris_y/MathGame.tetris_y/Program.cs @@ -5,6 +5,8 @@ class Program { static void Main(string[] args) { + List previousGames = new List(); + while (true) { Console.WriteLine("===== Welcome to the Math Game! ====="); @@ -12,27 +14,31 @@ static void Main(string[] args) Console.WriteLine("2. Subtraction"); Console.WriteLine("3. Multiplication"); Console.WriteLine("4. Division"); - Console.WriteLine("5. Exit"); + Console.WriteLine("5. Display game history"); + Console.WriteLine("0. Exit"); - Console.Write("Enter your choice (1-5):"); + Console.Write("Enter your choice (1-5): "); int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: Console.Clear(); - PerformCalculation(1); + previousGames.AddRange(PerformCalculation("+")); break; case 2: - PerformCalculation(2); + previousGames.AddRange(PerformCalculation("-")); break; case 3: - PerformCalculation(3); + previousGames.AddRange(PerformCalculation("*")); break; case 4: - PerformCalculation(4); + previousGames.AddRange(PerformCalculation("/")); break; case 5: + DisplayHistory(previousGames); + break; + case 0: Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Thank you for playing! Goodbye!\n"); Console.ResetColor(); @@ -46,36 +52,51 @@ static void Main(string[] args) } } - static void PerformCalculation(int operation) + static void DisplayHistory(List history) + { + Console.Clear(); + + foreach(string game in history) + { + Console.WriteLine(game); + } + + Console.Write("Press any key to continue..."); + Console.ReadLine(); + } + + static List PerformCalculation(string operation) { Random random = new Random(); + List history = new List(); for (int i = 0; i < 5; i++) { - int num1, num2; + int num1 = 0; + int num2 = 0; int correctAnswer = 0; switch (operation) { - case 1: + case "+": num1 = random.Next(1, 101); num2 = random.Next(1, 101); correctAnswer = num1 + num2; Console.Write($"What is {num1} + {num2}?: "); break; - case 2: + case "-": num1 = random.Next(1, 101); num2 = random.Next(1, 101); correctAnswer = num1 - num2; Console.Write($"What is {num1} - {num2}?: "); break; - case 3: + case "*": num1 = random.Next(1, 101); num2 = random.Next(1, 101); correctAnswer = num1 * num2; Console.Write($"What is {num1} * {num2}?: "); break; - case 4: + case "/": do { num1 = random.Next(1, 101); @@ -92,26 +113,18 @@ static void PerformCalculation(int operation) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Correct!\n"); - Console.ResetColor(); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Incorrect. The correct answer is {correctAnswer}.\n"); - Console.ResetColor(); } - } - } - static bool checkDivisonResult(int num1, int num2) - { - if (num1 % num2 == 0) - { - return true; - } else - { - return false; + history.Add($"Operation: {num1} {operation} {num2} Correct Answer: {correctAnswer} Your Answer: {userAnswer}"); + + Console.ResetColor(); } + return history; } } \ No newline at end of file