From 8eab15fcfc681794d53bd8f1ed44b40cc0627a9a Mon Sep 17 00:00:00 2001
From: Tenebris-06 <107663992+Tenebris-06@users.noreply.github.com>
Date: Mon, 23 Feb 2026 05:56:38 +0200
Subject: [PATCH 1/5] MenuOptionEnum & Problem class
---
CodeReviews.Console.MathGame.sln | 24 +++++++++++++++++
Tenebris-06.MathGame/MenuOptionEnum.cs | 7 +++++
Tenebris-06.MathGame/Problem.cs | 25 +++++++++++++++++
Tenebris-06.MathGame/ProblemGenerator.cs | 7 +++++
Tenebris-06.MathGame/Program.cs | 27 +++++++++++++++++++
.../Tenebris-06.MathGame.csproj | 11 ++++++++
6 files changed, 101 insertions(+)
create mode 100644 CodeReviews.Console.MathGame.sln
create mode 100644 Tenebris-06.MathGame/MenuOptionEnum.cs
create mode 100644 Tenebris-06.MathGame/Problem.cs
create mode 100644 Tenebris-06.MathGame/ProblemGenerator.cs
create mode 100644 Tenebris-06.MathGame/Program.cs
create mode 100644 Tenebris-06.MathGame/Tenebris-06.MathGame.csproj
diff --git a/CodeReviews.Console.MathGame.sln b/CodeReviews.Console.MathGame.sln
new file mode 100644
index 00000000..344bf09b
--- /dev/null
+++ b/CodeReviews.Console.MathGame.sln
@@ -0,0 +1,24 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.2.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tenebris-06.MathGame", "Tenebris-06.MathGame\Tenebris-06.MathGame.csproj", "{3E3BF72D-9C95-C189-A25A-77F3C1042C60}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {3E3BF72D-9C95-C189-A25A-77F3C1042C60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3E3BF72D-9C95-C189-A25A-77F3C1042C60}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3E3BF72D-9C95-C189-A25A-77F3C1042C60}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3E3BF72D-9C95-C189-A25A-77F3C1042C60}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1F3971B0-9543-463C-8B64-17441F96B5FB}
+ EndGlobalSection
+EndGlobal
diff --git a/Tenebris-06.MathGame/MenuOptionEnum.cs b/Tenebris-06.MathGame/MenuOptionEnum.cs
new file mode 100644
index 00000000..1195a3fc
--- /dev/null
+++ b/Tenebris-06.MathGame/MenuOptionEnum.cs
@@ -0,0 +1,7 @@
+public enum MenuOption
+{
+ Add = 1,
+ Subtract,
+ Multiply,
+ Divide
+}
\ No newline at end of file
diff --git a/Tenebris-06.MathGame/Problem.cs b/Tenebris-06.MathGame/Problem.cs
new file mode 100644
index 00000000..cf1712ef
--- /dev/null
+++ b/Tenebris-06.MathGame/Problem.cs
@@ -0,0 +1,25 @@
+public class Problem
+{
+ public string Text;
+ public string Answer;
+
+ public void setText(string Text)
+ {
+ this.Text = Text;
+ }
+
+ public void setAnswer(string Answer)
+ {
+ this.Answer = Answer;
+ }
+
+ public string getText()
+ {
+ return Text;
+ }
+
+ public string getAnswer()
+ {
+ return Answer;
+ }
+}
\ No newline at end of file
diff --git a/Tenebris-06.MathGame/ProblemGenerator.cs b/Tenebris-06.MathGame/ProblemGenerator.cs
new file mode 100644
index 00000000..a3bda5e2
--- /dev/null
+++ b/Tenebris-06.MathGame/ProblemGenerator.cs
@@ -0,0 +1,7 @@
+public static class ProblemGenerator
+{
+ public static Problem generateProblem(MenuOption operatorValue)
+ {
+ return new Problem();
+ }
+}
\ No newline at end of file
diff --git a/Tenebris-06.MathGame/Program.cs b/Tenebris-06.MathGame/Program.cs
new file mode 100644
index 00000000..531f3352
--- /dev/null
+++ b/Tenebris-06.MathGame/Program.cs
@@ -0,0 +1,27 @@
+using System.Net;
+
+class Program
+{
+ static void Main(string[] args)
+ {
+ Console.WriteLine("\t====== Math Game ======\nPick an Option:");
+ Console.WriteLine("[1] Addition \n[2] Subtraction \n[3]Multiplication \n[4] Division");
+
+ int userChoice;
+ if (int.TryParse(Console.ReadLine(), out userChoice))
+ {
+
+ } else
+ {
+ Console.WriteLine("Invalid Input!");
+ }
+
+ for (int i = 0; i <= 4; i++)
+ {
+ // cast the userChoice to it's corresponding enum option
+
+ Problem generatedProblem = ProblemGenerator.generateProblem((MenuOption)userChoice);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Tenebris-06.MathGame/Tenebris-06.MathGame.csproj b/Tenebris-06.MathGame/Tenebris-06.MathGame.csproj
new file mode 100644
index 00000000..2f23d3c0
--- /dev/null
+++ b/Tenebris-06.MathGame/Tenebris-06.MathGame.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net9.0
+ Tenebris_06.MathGame
+ enable
+ enable
+
+
+
From 8c2f0ec6260532c61e120cddf880323055526eb5 Mon Sep 17 00:00:00 2001
From: Tenebris-06 <107663992+Tenebris-06@users.noreply.github.com>
Date: Sat, 28 Feb 2026 06:39:18 +0200
Subject: [PATCH 2/5] Problem Generator and Game Class
---
Tenebris-06.MathGame/Game.cs | 0
Tenebris-06.MathGame/Problem.cs | 13 +++--
Tenebris-06.MathGame/ProblemGenerator.cs | 63 +++++++++++++++++++++++-
Tenebris-06.MathGame/Program.cs | 11 ++++-
4 files changed, 82 insertions(+), 5 deletions(-)
create mode 100644 Tenebris-06.MathGame/Game.cs
diff --git a/Tenebris-06.MathGame/Game.cs b/Tenebris-06.MathGame/Game.cs
new file mode 100644
index 00000000..e69de29b
diff --git a/Tenebris-06.MathGame/Problem.cs b/Tenebris-06.MathGame/Problem.cs
index cf1712ef..a113a85d 100644
--- a/Tenebris-06.MathGame/Problem.cs
+++ b/Tenebris-06.MathGame/Problem.cs
@@ -1,14 +1,21 @@
public class Problem
{
public string Text;
- public string Answer;
+ public int Answer;
+
+
+ public Problem(string Text, int Answer)
+ {
+ this.Text = Text;
+ this.Answer = Answer;
+ }
public void setText(string Text)
{
this.Text = Text;
}
- public void setAnswer(string Answer)
+ public void setAnswer(int Answer)
{
this.Answer = Answer;
}
@@ -18,7 +25,7 @@ public string getText()
return Text;
}
- public string getAnswer()
+ public int getAnswer()
{
return Answer;
}
diff --git a/Tenebris-06.MathGame/ProblemGenerator.cs b/Tenebris-06.MathGame/ProblemGenerator.cs
index a3bda5e2..e5ddc769 100644
--- a/Tenebris-06.MathGame/ProblemGenerator.cs
+++ b/Tenebris-06.MathGame/ProblemGenerator.cs
@@ -1,7 +1,68 @@
+using Microsoft.VisualBasic;
+
public static class ProblemGenerator
{
+ static Random randomizer = new Random();
+ static int rand1;
+ static int rand2;
public static Problem generateProblem(MenuOption operatorValue)
{
- return new Problem();
+ do
+ {
+ rand1 = randomizer.Next(10);
+ rand2 = randomizer.Next(10);
+
+ if (!(operatorValue == MenuOption.Divide)) break;
+
+ } while (rand1 % rand2 != 0);
+
+ string problemText = $"{rand1} {GetOperator(operatorValue)} {rand2} = ?";
+ int problemAnswer = -1;
+
+ switch (operatorValue)
+ {
+ case MenuOption.Add:
+ problemAnswer = rand1 + rand2;
+ break;
+
+ case MenuOption.Subtract:
+ problemAnswer = rand1 - rand2;
+ break;
+
+ case MenuOption.Multiply:
+ problemAnswer = rand1 * rand2;
+ break;
+
+ case MenuOption.Divide:
+ problemAnswer = rand1 / rand1;
+ break;
+
+ default:
+ break;
+ }
+
+ return new Problem(problemText, problemAnswer);
+
+ }
+
+ public static string GetOperator(MenuOption operatorValue)
+ {
+ switch (operatorValue)
+ {
+ case MenuOption.Add:
+ return "+";
+
+ case MenuOption.Subtract:
+ return "-";
+
+ case MenuOption.Multiply:
+ return "*";
+
+ case MenuOption.Divide:
+ return "/";
+
+ default:
+ return "";
+ }
}
}
\ No newline at end of file
diff --git a/Tenebris-06.MathGame/Program.cs b/Tenebris-06.MathGame/Program.cs
index 531f3352..840a4334 100644
--- a/Tenebris-06.MathGame/Program.cs
+++ b/Tenebris-06.MathGame/Program.cs
@@ -5,7 +5,7 @@ class Program
static void Main(string[] args)
{
Console.WriteLine("\t====== Math Game ======\nPick an Option:");
- Console.WriteLine("[1] Addition \n[2] Subtraction \n[3]Multiplication \n[4] Division");
+ Console.WriteLine("[1] Addition \n[2] Subtraction \n[3] Multiplication \n[4] Division");
int userChoice;
if (int.TryParse(Console.ReadLine(), out userChoice))
@@ -21,6 +21,15 @@ static void Main(string[] args)
// cast the userChoice to it's corresponding enum option
Problem generatedProblem = ProblemGenerator.generateProblem((MenuOption)userChoice);
+ Console.WriteLine($"\t == Problem {i}: ==");
+ Console.WriteLine($"{generatedProblem.Text}");
+ Console.Write("=>");
+ int.TryParse(Console.ReadLine(), out int userAnswer);
+
+ if (userAnswer == generatedProblem.Answer)
+ {
+ Console.WriteLine("Correct!");
+ }
}
}
From 6d8d22c109670e3b0d0ee7057fdfeb5014e0eb9d Mon Sep 17 00:00:00 2001
From: Tenebris-06 <107663992+Tenebris-06@users.noreply.github.com>
Date: Sat, 28 Feb 2026 09:16:43 +0200
Subject: [PATCH 3/5] Game History & Scoring System
---
Tenebris-06.MathGame/Game.cs | 10 +++++
Tenebris-06.MathGame/MenuOptionEnum.cs | 4 +-
Tenebris-06.MathGame/Problem.cs | 29 +++++++++++++
Tenebris-06.MathGame/ProblemGenerator.cs | 4 +-
Tenebris-06.MathGame/Program.cs | 54 ++++++++++++++++++++++--
5 files changed, 94 insertions(+), 7 deletions(-)
diff --git a/Tenebris-06.MathGame/Game.cs b/Tenebris-06.MathGame/Game.cs
index e69de29b..56881b42 100644
--- a/Tenebris-06.MathGame/Game.cs
+++ b/Tenebris-06.MathGame/Game.cs
@@ -0,0 +1,10 @@
+public class Game
+{
+ public int score;
+ public List problemSet;
+ public Game(int score, List problemSet)
+ {
+ this.score = score;
+ this.problemSet = problemSet;
+ }
+}
\ No newline at end of file
diff --git a/Tenebris-06.MathGame/MenuOptionEnum.cs b/Tenebris-06.MathGame/MenuOptionEnum.cs
index 1195a3fc..cfd90813 100644
--- a/Tenebris-06.MathGame/MenuOptionEnum.cs
+++ b/Tenebris-06.MathGame/MenuOptionEnum.cs
@@ -1,7 +1,9 @@
public enum MenuOption
{
+ Exit = 0,
Add = 1,
Subtract,
Multiply,
- Divide
+ Divide,
+ History
}
\ No newline at end of file
diff --git a/Tenebris-06.MathGame/Problem.cs b/Tenebris-06.MathGame/Problem.cs
index a113a85d..0f8e6ecf 100644
--- a/Tenebris-06.MathGame/Problem.cs
+++ b/Tenebris-06.MathGame/Problem.cs
@@ -2,6 +2,8 @@ public class Problem
{
public string Text;
public int Answer;
+ public int UserAnswer;
+ public bool CorrectlyAnswered;
public Problem(string Text, int Answer)
@@ -29,4 +31,31 @@ public int getAnswer()
{
return Answer;
}
+
+ public void setUserAnswer(int userAnswer)
+ {
+ this.UserAnswer = userAnswer;
+ }
+
+ public int getUserAnswer()
+ {
+ return UserAnswer;
+ }
+
+ public string ToString()
+ {
+ string AnswerState;
+
+ switch (CorrectlyAnswered)
+ {
+ case true:
+ AnswerState = "✔";
+ break;
+
+ case false:
+ AnswerState = "✘";
+ break;
+ }
+ return $"{Text.PadRight(12)}{UserAnswer.ToString().PadRight(12)}{Answer.ToString().PadRight(12)}{AnswerState.ToString().PadLeft(10)}";
+ }
}
\ No newline at end of file
diff --git a/Tenebris-06.MathGame/ProblemGenerator.cs b/Tenebris-06.MathGame/ProblemGenerator.cs
index e5ddc769..ad27db1b 100644
--- a/Tenebris-06.MathGame/ProblemGenerator.cs
+++ b/Tenebris-06.MathGame/ProblemGenerator.cs
@@ -14,7 +14,7 @@ public static Problem generateProblem(MenuOption operatorValue)
if (!(operatorValue == MenuOption.Divide)) break;
- } while (rand1 % rand2 != 0);
+ } while (rand2 == 0 || rand1 % rand2 != 0);
string problemText = $"{rand1} {GetOperator(operatorValue)} {rand2} = ?";
int problemAnswer = -1;
@@ -34,7 +34,7 @@ public static Problem generateProblem(MenuOption operatorValue)
break;
case MenuOption.Divide:
- problemAnswer = rand1 / rand1;
+ problemAnswer = rand1 / rand2;
break;
default:
diff --git a/Tenebris-06.MathGame/Program.cs b/Tenebris-06.MathGame/Program.cs
index 840a4334..b7bae435 100644
--- a/Tenebris-06.MathGame/Program.cs
+++ b/Tenebris-06.MathGame/Program.cs
@@ -4,8 +4,14 @@ class Program
{
static void Main(string[] args)
{
+
+ List gameHistory = new List();
+
+ while (true) {
+
Console.WriteLine("\t====== Math Game ======\nPick an Option:");
- Console.WriteLine("[1] Addition \n[2] Subtraction \n[3] Multiplication \n[4] Division");
+ Console.WriteLine("[1] Addition \n[2] Subtraction \n[3] Multiplication \n[4] Division \n[5] History \n[0] Exit");
+ Console.Write("=> ");
int userChoice;
if (int.TryParse(Console.ReadLine(), out userChoice))
@@ -16,21 +22,61 @@ static void Main(string[] args)
Console.WriteLine("Invalid Input!");
}
+ if ((MenuOption)userChoice == MenuOption.History)
+ {
+ Console.WriteLine("\t=== Game History ===");
+
+ for (int i = 0; i <= gameHistory.Count - 1; i++)
+ {
+ Console.WriteLine($"\n[Game {i + 1}] (Score: {gameHistory[i].score})");
+ Console.WriteLine($"{"Problem".PadRight(12)}{"Your Answer".PadRight(12)}{"Correct Answer".PadRight(12)}{"Status".PadLeft(10)}");
+ foreach (Problem p in gameHistory[i].problemSet)
+ {
+ Console.WriteLine(p.ToString());
+ }
+ }
+
+ Console.WriteLine("Press any key to go back to main menu => ");
+ Console.ReadKey();
+ continue;
+
+ } else if ((MenuOption)userChoice == MenuOption.Exit)
+ {
+ Console.WriteLine("Goodbye!");
+ Environment.Exit(0);
+ }
+
+ int score = 0;
+ List ProblemSet = new List();
+
for (int i = 0; i <= 4; i++)
{
// cast the userChoice to it's corresponding enum option
Problem generatedProblem = ProblemGenerator.generateProblem((MenuOption)userChoice);
+ ProblemSet.Add(generatedProblem);
Console.WriteLine($"\t == Problem {i}: ==");
Console.WriteLine($"{generatedProblem.Text}");
- Console.Write("=>");
+ Console.Write("=> ");
int.TryParse(Console.ReadLine(), out int userAnswer);
+
+ generatedProblem.setUserAnswer(userAnswer);
if (userAnswer == generatedProblem.Answer)
{
Console.WriteLine("Correct!");
- }
+ generatedProblem.CorrectlyAnswered = true;
+ score++;
+ } else
+ {
+ Console.WriteLine("Wrong!");
+ generatedProblem.CorrectlyAnswered = false;
+ }
}
+ Game currentGame = new Game(score, ProblemSet);
+ gameHistory.Add(currentGame);
+
}
-}
\ No newline at end of file
+}
+}
From 1db5e799e64d6026e0b39814a9f7934a9f214f2d Mon Sep 17 00:00:00 2001
From: Tenebris-06 <107663992+Tenebris-06@users.noreply.github.com>
Date: Sun, 1 Mar 2026 00:41:04 +0200
Subject: [PATCH 4/5] fix method naming
---
Tenebris-06.MathGame/Problem.cs | 16 ++++++++--------
Tenebris-06.MathGame/ProblemGenerator.cs | 2 +-
Tenebris-06.MathGame/Program.cs | 4 ++--
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Tenebris-06.MathGame/Problem.cs b/Tenebris-06.MathGame/Problem.cs
index 0f8e6ecf..ac374f74 100644
--- a/Tenebris-06.MathGame/Problem.cs
+++ b/Tenebris-06.MathGame/Problem.cs
@@ -12,37 +12,37 @@ public Problem(string Text, int Answer)
this.Answer = Answer;
}
- public void setText(string Text)
+ public void SetText(string Text)
{
this.Text = Text;
}
- public void setAnswer(int Answer)
+ public void SetAnswer(int Answer)
{
this.Answer = Answer;
}
- public string getText()
+ public string GetText()
{
return Text;
}
- public int getAnswer()
+ public int GetAnswer()
{
return Answer;
}
- public void setUserAnswer(int userAnswer)
+ public void SetUserAnswer(int userAnswer)
{
this.UserAnswer = userAnswer;
}
- public int getUserAnswer()
+ public int GetUserAnswer()
{
return UserAnswer;
}
- public string ToString()
+ public override string ToString()
{
string AnswerState;
@@ -56,6 +56,6 @@ public string ToString()
AnswerState = "✘";
break;
}
- return $"{Text.PadRight(12)}{UserAnswer.ToString().PadRight(12)}{Answer.ToString().PadRight(12)}{AnswerState.ToString().PadLeft(10)}";
+ return $"{Text.PadRight(12)}{UserAnswer.ToString().PadRight(12)}{Answer.ToString().PadRight(12)}{AnswerState.PadLeft(10)}";
}
}
\ No newline at end of file
diff --git a/Tenebris-06.MathGame/ProblemGenerator.cs b/Tenebris-06.MathGame/ProblemGenerator.cs
index ad27db1b..7e4845e9 100644
--- a/Tenebris-06.MathGame/ProblemGenerator.cs
+++ b/Tenebris-06.MathGame/ProblemGenerator.cs
@@ -5,7 +5,7 @@ public static class ProblemGenerator
static Random randomizer = new Random();
static int rand1;
static int rand2;
- public static Problem generateProblem(MenuOption operatorValue)
+ public static Problem GenerateProblem(MenuOption operatorValue)
{
do
{
diff --git a/Tenebris-06.MathGame/Program.cs b/Tenebris-06.MathGame/Program.cs
index b7bae435..b5cc57b2 100644
--- a/Tenebris-06.MathGame/Program.cs
+++ b/Tenebris-06.MathGame/Program.cs
@@ -53,14 +53,14 @@ static void Main(string[] args)
{
// cast the userChoice to it's corresponding enum option
- Problem generatedProblem = ProblemGenerator.generateProblem((MenuOption)userChoice);
+ Problem generatedProblem = ProblemGenerator.GenerateProblem((MenuOption)userChoice);
ProblemSet.Add(generatedProblem);
Console.WriteLine($"\t == Problem {i}: ==");
Console.WriteLine($"{generatedProblem.Text}");
Console.Write("=> ");
int.TryParse(Console.ReadLine(), out int userAnswer);
- generatedProblem.setUserAnswer(userAnswer);
+ generatedProblem.SetUserAnswer(userAnswer);
if (userAnswer == generatedProblem.Answer)
{
From d54c415e3df632ebf2ab379a1945cd65b877f1ef Mon Sep 17 00:00:00 2001
From: Tenebris-06 <107663992+Tenebris-06@users.noreply.github.com>
Date: Sun, 1 Mar 2026 00:55:33 +0200
Subject: [PATCH 5/5] Remove unnecessary namespaces
---
Tenebris-06.MathGame/ProblemGenerator.cs | 2 --
Tenebris-06.MathGame/Program.cs | 10 +++-------
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/Tenebris-06.MathGame/ProblemGenerator.cs b/Tenebris-06.MathGame/ProblemGenerator.cs
index 7e4845e9..4d7358d9 100644
--- a/Tenebris-06.MathGame/ProblemGenerator.cs
+++ b/Tenebris-06.MathGame/ProblemGenerator.cs
@@ -1,5 +1,3 @@
-using Microsoft.VisualBasic;
-
public static class ProblemGenerator
{
static Random randomizer = new Random();
diff --git a/Tenebris-06.MathGame/Program.cs b/Tenebris-06.MathGame/Program.cs
index b5cc57b2..5f3aaec3 100644
--- a/Tenebris-06.MathGame/Program.cs
+++ b/Tenebris-06.MathGame/Program.cs
@@ -1,6 +1,4 @@
-using System.Net;
-
-class Program
+class Program
{
static void Main(string[] args)
{
@@ -14,10 +12,8 @@ static void Main(string[] args)
Console.Write("=> ");
int userChoice;
- if (int.TryParse(Console.ReadLine(), out userChoice))
- {
-
- } else
+
+ if (!(int.TryParse(Console.ReadLine(), out userChoice)))
{
Console.WriteLine("Invalid Input!");
}