Added first code.

Signed-off-by: Naoriel Sa' Rocí <naoriel@sa-roci.de>
This commit is contained in:
2026-03-30 02:26:31 +02:00
parent bbf68e1621
commit 4a4fb54143
25 changed files with 1072 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
using EinmaleinsTrainer.Models;
using System;
using System.Linq;
using System.Collections.Generic;
namespace EinmaleinsTrainer.Services;
public class QuestionGenerator
{
private readonly Random _random = new();
public List<Question> Generate(List<int> rows, bool includeSquares)
{
var pool = new List<Question>();
foreach (var r in rows)
{
for (int i = 1; i <= 10; i++)
pool.Add(new Question { A = r, B = i });
}
if (includeSquares)
{
for (int i = 1; i <= 10; i++)
pool.Add(new Question { A = i, B = i });
}
return pool.OrderBy(_ => _random.Next())
.Take(10)
.ToList();
}
}