Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Rakenkode.MathGame/.idea/.idea.Rakenkode.MathGame/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Rakenkode.MathGame/Rakenkode.MathGame.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rakenkode.MathGame", "Rakenkode.MathGame\Rakenkode.MathGame.csproj", "{A6E9053C-DFA6-44F4-AECA-B67B162FA2FC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A6E9053C-DFA6-44F4-AECA-B67B162FA2FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6E9053C-DFA6-44F4-AECA-B67B162FA2FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6E9053C-DFA6-44F4-AECA-B67B162FA2FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6E9053C-DFA6-44F4-AECA-B67B162FA2FC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
41 changes: 41 additions & 0 deletions Rakenkode.MathGame/Rakenkode.MathGame/Game.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace Rakenkode.MathGame;

public class Game
{
private double _rating = 0;
public double Rating
{
get { return _rating; }
}
public int Duration { get; set; }
public GameType GameType { get;}
public Question[] Questions;

public Game(GameType gameType, int numberOfQuestions)
{
GameType = gameType;
Questions = new Question[numberOfQuestions];
Questions = Question.CreateProblems(gameType, numberOfQuestions);
}

public void Evaluate()
{
int score = 0;

for (int i = 0; i < Questions.Length; i++)
{
if (Questions[i].IsPlayerCorrect())
score++;
}
_rating = Math.Round((score / (double) Questions.Length) * 100, 1);
}
}

public enum GameType
{
Addition = 0,
Subtraction = 1,
Multiplication = 2,
Division = 3,
Random = 4
}
Loading