private static void RunProblems(Problem problem, StoryManager storyManager, IList <int> options, string storyName) { Console.WriteLine(problem.Text); Console.WriteLine(); if (problem.Options == null || problem.Options.Count == 0) { return; } foreach (ReadModel.Option option in problem.Options) { Console.WriteLine("{0}) {1}", option.Number, option.Text); } int chosenOption = 0; while (!int.TryParse(Console.ReadLine(), out chosenOption) || problem.Options.All(op => op.Number != chosenOption)) { Console.WriteLine("Invalid option."); } options.Add(chosenOption); var nextProblem = storyManager.GetNextProblem(storyName, options); RunProblems(nextProblem, storyManager, options, storyName); }
private static void RunProblems(Problem problem, StoryManager storyManager, IList<int> options, string storyName) { Console.WriteLine(problem.Text); Console.WriteLine(); if (problem.Options == null || problem.Options.Count == 0) { return; } foreach (ReadModel.Option option in problem.Options) { Console.WriteLine("{0}) {1}", option.Number, option.Text); } int chosenOption = 0; while (!int.TryParse(Console.ReadLine(), out chosenOption) || problem.Options.All(op => op.Number != chosenOption)) { Console.WriteLine("Invalid option."); } options.Add(chosenOption); var nextProblem = storyManager.GetNextProblem(storyName, options); RunProblems(nextProblem, storyManager, options, storyName); }