/// <summary> /// Displays a question to the user. /// </summary> private static void DisplayQuestion(Engine.Response response) { // Get data about the next question Facts.Fact theFact = response.NextFact; Question theQ = Templates.GetQ(theFact.Relationship); // TODO: Display appropriate question control (using theQ.questionType) // White space Console.WriteLine(); // Display progress percentage Console.WriteLine("Percent complete: " + response.PercentComplete); // Display question text string qText = theFact.QuestionText(); // QuestionText(theFact, theQ); Console.WriteLine(qText); AkkTest.assertedRelationship = AkkTest.AddUnitTestAssertRel(theFact, theQ); // Display an explanation (if any) if (theQ.explanation != "") { Console.WriteLine("Note: " + theQ.explanation); } }
/// <summary> /// Sets/resets data structures for new interview session. /// </summary> public static void InitializeSession() { // Clear fact base and assert any assumed facts Facts.Clear(); AssertPreliminaryFacts(); // Initialize the .akk unit test text string AkkTest.testStr = ""; AkkTest.InitializeUnitTest(); }
/// <summary> /// Displays the engine's results of the interview session. /// </summary> private static void DisplayResults(Facts.Fact goal) { Console.WriteLine("\n"); // Indent and format results string tline = "\t" + goal.ValueAsString().Replace("\n", "\n\t"); // For eternal values, only show value if (goal.Value().IsEternal) { tline = tline.Replace("DawnOfTime ", ""); } // Concatenate question and answer string result = "\t" + goal.QuestionText() + "\n\n" + tline + "\n"; // Add result to test case Tvar testResult = goal.GetFunction().Invoke(); AkkTest.CloseUnitTest(testResult, goal.Relationship); Console.WriteLine(result); }
public static void Main(string[] args) { // Just for fun... // Console.ForegroundColor = ConsoleColor.Green; Console.Title = "Hammura.bi Interactive"; // Console.WindowWidth = 100; // Console.WindowHeight = 40; // Console.WriteLine("Welcome to the Hammura.bi knowledge base.\n\n"); // Ask the user what goal they want to investigate Console.WriteLine("Enter a goal to test:\n"); string goal = Console.ReadLine(); // Main loop - runs the interview multiple times while (true) { // If invalid goal, prompt for new goal // try // { // Run the interview Interview.ProcessRequest(goal); // Next action Console.WriteLine("Repeat? r"); Console.WriteLine("Save? s"); Console.WriteLine("New topic? n"); string next = Console.ReadLine(); // Save interview as an .akk test if (next == "s") { string file = Interactive.Templates.GetQ(goal.Split(' ')[0]).filePath; AkkTest.WriteToFile(file); // Next action Console.WriteLine("\nTest case saved.\n"); Console.WriteLine("Repeat? r"); Console.WriteLine("New topic? n"); next = Console.ReadLine(); } // Switch to a new interview topic if (next == "n") { Console.WriteLine("\nEnter a goal to test:\n"); goal = Console.ReadLine(); } // Continue session or quit if (next == "r" || next == "n") { } else { break; } // } // catch // { // Console.WriteLine("\nInvalid request. Enter goal:"); // goal = Console.ReadLine(); // } } }