Esempio n. 1
0
        static void TrySolveProblem(Problem problem, IEnumerable <ISolver> solvers)
        {
            foreach (var solver in solvers)
            {
                // TODO: try to solve problem using solver

                if (problem.Solved)
                {
                    break;
                }

                problem.Accept(solver);
            }

            if (problem.Solved)
            {
                Console.WriteLine($"Result of {problem.Name}: {problem.Result}");
            }
            else
            {
                Console.WriteLine($"{problem.Name} was not solved");
            }

            Console.WriteLine(string.Empty);
        }
Esempio n. 2
0
 /// <summary>
 /// Checks the given problem data.
 /// </summary>
 /// <param name="problem">Problem input data.</param>
 public void CheckProblem(Problem problem)
 {
     ProblemContext = problem;
     problem.Accept(this);
 }