-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (32 loc) · 1.27 KB
/
Program.cs
File metadata and controls
40 lines (32 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Linq;
using Questionnaire.Services;
class Program
{
static void Main(string[] args)
{
var questionRepository = new InMemoryQuestionRepository();
var questionnaire = new Questionnaire.Services.Questionnaire(questionRepository.GetAll());
// Start the interactive session
StartInteractiveSession(questionnaire);
}
static void StartInteractiveSession(Questionnaire.Services.Questionnaire questionnaire)
{
Console.WriteLine("Welcome to the Muinmos questionnaire!");
while (true)
{
Console.WriteLine("Ask your question (type 'exit' to end):");
var input = Console.ReadLine();
if (input.ToLower() == "exit")
break;
var answer = GetAnswer(input, questionnaire);
Console.WriteLine($"Answer: {answer}");
}
Console.WriteLine("Thank you for using the Muinmos questionnaire!");
}
static string GetAnswer(string question, Questionnaire.Services.Questionnaire questionnaire)
{
var matchedQuestion = questionnaire.Questions.FirstOrDefault(q => q.Text.ToLower() == question.ToLower());
return matchedQuestion?.Answer ?? "I'm sorry, I don't have an answer to that question.";
}
}