コード例 #1
0
    public BinaryProblem(Level level)
    {
        ProblemConfiguration configuration = _levelConfiguration.GetProblemConfiguration(level);

        // sample code, this is where you generate your problem, based on the configuration of the problem
        X      = new Random().Next(configuration.MaxValue + configuration.MinValue) - configuration.MinValue;
        Y      = new Random().Next(configuration.MaxValue + configuration.MinValue) - configuration.MinValue;
        Answer = X + Y;
    }
コード例 #2
0
    static void Main(string[] args)
    {
        ProblemFactory           problemFactory    = new ProblemFactory();
        BinaryLevelConfiguration binaryLevelConfig = new BinaryLevelConfiguration();

        // register your factory functions
        problemFactory.RegisterProblem <BinaryProblem>((level) => new BinaryProblem(binaryLevelConfig.GetProblemConfiguration(level)));
        // consume them
        IProblem problem1 = problemFactory.GenerateProblem <BinaryProblem>(Level.Easy);
        IProblem problem2 = problemFactory.GenerateProblem <BinaryProblem>(Level.Hard);
    }