private static void RunStory(string storyName) { var storyManager = new StoryManager(new StoryReadRepository(), new StoryRepository()); var story = storyManager.GetStory(storyName); Console.WriteLine(story.Name); Console.WriteLine(); RunProblems(story.FirstProblem, storyManager, new List<int>(), storyName); Console.ReadKey(); }
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); }