//weergeeft de vraag aabn de gebruiker. public void presentQuestion(IQuestionable q) { q.geefVraag(); Console.WriteLine("antwoord: "); string response = Console.ReadLine(); Console.WriteLine(q.checkAnswer(response)); Console.WriteLine("volgende vraag? druk op een toets. als er geen vragen meer zijn wordt de applicatie afgesloten."); Console.ReadKey(true); }
static double CalculateArea(IQuestionable subject) { var shape = subject.Ask("What shape is it?"); switch (shape.ToLowerInvariant()) { case "rectangle": var(width, height) = subject.Ask("How wide is the rectangle?", "How tall is the rectangle?"); return(double.Parse(width) * double.Parse(height)); case "circle": var radius = double.Parse(subject.Ask("What is the circle's radius?")); return(radius * radius * Math.PI); default: throw new Exception("Unsupported shape"); } }
private static ElementManagerLeaf CreateElementManager(IQuestionable identifiedNode, ExpressionBool condition, ElementManagerCollection parent, ElementManagerController elementManagerController, ExpressionValue activationExpression) { switch (identifiedNode.ValueType) { case QValueType.Boolean: return(new BoolQuestionManager(identifiedNode.ID, identifiedNode.Text, parent, elementManagerController, condition, activationExpression as ExpressionBool)); case QValueType.Integer: return(new IntQuestionManager(identifiedNode.ID, identifiedNode.Text, parent, elementManagerController, condition, activationExpression as ExpressionInt)); case QValueType.Text: return(new StringQuestionManager(identifiedNode.ID, identifiedNode.Text, parent, elementManagerController, condition, activationExpression as ExpressionText)); case QValueType.Money: return(new MoneyQuestionManager(identifiedNode.ID, identifiedNode.Text, parent, elementManagerController, condition, activationExpression as ExpressionDouble)); case QValueType.Hex: return(new HexQuestionManager(identifiedNode.ID, identifiedNode.Text, parent, elementManagerController, condition, activationExpression as ExpressionHex)); } throw new InvalidOperationException("Unsupported type: " + identifiedNode.ValueType); }
//voegt vraag toe aan vragenLijst. public void addVraag(IQuestionable Q) { vragenLijst.Add(Q); }
public static (string, string) Ask(this IQuestionable questionable, string question1, string question2) { var answers = questionable.Ask(new[] { question1, question2 }); return(answers[0], answers[1]); }
public static string Ask(this IQuestionable questionable, string question) { var answers = questionable.Ask(new[] { question }); return(answers[0]); }