本文整理汇总了C#中Question.addAnswer方法的典型用法代码示例。如果您正苦于以下问题:C# Question.addAnswer方法的具体用法?C# Question.addAnswer怎么用?C# Question.addAnswer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question.addAnswer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: importQuestions
public QuestionSet importQuestions() {
StreamReader file = new StreamReader(DATABASE_NAME);
QuestionSet importedQuestionSet = new QuestionSet();
string line;
while((line = file.ReadLine()) != null) {
string[] split = line.Split('|');
Question question = new Question(split[1], (Question.QuestionType) System.Enum.Parse(typeof(Question.QuestionType), split[0], false));
for (int i = 2; i < split.Length; i += 2) {
question.addAnswer(split[i], System.Convert.ToBoolean(split[i+1]));
}
importedQuestionSet.addQuestion(question);
}
file.Close();
return importedQuestionSet;
}
示例2: onQuestionSave
public void onQuestionSave() {
Question question = new Question(inputQuestion.text, mode);
if (inputQuestion.text == "") {
EditorUtility.DisplayDialog ("Upozorenje", "Niste unijeli tekst pitanja.", "U redu");
return;
}
switch(mode) {
case Question.QuestionType.MODE2_V:
if (inputField1.text == "" || inputField2.text == "") {
EditorUtility.DisplayDialog ("Upozorenje", "Niste unijeli odgovore.", "U redu");
return;
}
if (!(toggle1.isOn || toggle2.isOn)) {
EditorUtility.DisplayDialog ("Upozorenje", "Niste označili niti jedan odgovor kao točan odgovor.", "U redu");
return;
}
question.addAnswer(inputField1.text, toggle1.isOn);
question.addAnswer(inputField2.text, toggle2.isOn);
break;
case Question.QuestionType.MODE2_H:
if (inputField1.text == "" || inputField3.text == "") {
EditorUtility.DisplayDialog ("Upozorenje", "Niste unijeli odgovore.", "U redu");
return;
}
if (!(toggle1.isOn || toggle3.isOn)) {
EditorUtility.DisplayDialog ("Upozorenje", "Niste označili niti jedan odgovor kao točan odgovor.", "U redu");
return;
}
question.addAnswer(inputField1.text, toggle1.isOn);
question.addAnswer(inputField3.text, toggle3.isOn);
break;
case Question.QuestionType.MODE4:
if (inputField1.text == "" || inputField2.text == "" || inputField3.text == "" || inputField4.text == "") {
EditorUtility.DisplayDialog ("Upozorenje", "Niste unijeli odgovore.", "U redu");
return;
}
if (!(toggle1.isOn || toggle2.isOn || toggle3.isOn || toggle4.isOn)) {
EditorUtility.DisplayDialog ("Upozorenje", "Niste označili niti jedan odgovor kao točan odgovor.", "U redu");
return;
}
question.addAnswer(inputField1.text, toggle1.isOn);
question.addAnswer(inputField2.text, toggle2.isOn);
question.addAnswer(inputField3.text, toggle3.isOn);
question.addAnswer(inputField4.text, toggle4.isOn);
break;
default:
EditorUtility.DisplayDialog ("Upozorenje", "Niste odabrali modalitet igre.", "U redu");
return;
}
questionSet.addQuestion(question);
questionNumber += 1;
questionNumberText.text = questionNumber.ToString();
inputQuestion.text = inputField1.text = inputField2.text = inputField3.text = inputField4.text = "";
toggle1.isOn = toggle2.isOn = toggle3.isOn = toggle4.isOn = false;
}