private static void AddNewQuestion() { Console.Clear(); Console.WriteLine("Geben Sie eine neue Frage ein"); String question = Console.ReadLine(); Console.Clear(); Console.WriteLine("Geben Sie die dazugehörende Antwort ein"); String answer = Console.ReadLine(); Console.Clear(); Console.WriteLine("Geben Sie das Themengebiet ein"); String topic = Console.ReadLine(); Console.Clear(); QuestionAnswerPair q = new QuestionAnswerPair(question, answer, topic); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(q.GetType()); TextWriter writer = new StreamWriter(topic + Guid.NewGuid() + ".xml"); x.Serialize(writer, q); _questionPool.Add(question, answer, topic); }
public void Start() { InitPlayers(); bool isOver = false; while (!isOver) { foreach (Player player in _players) { Console.Clear(); Console.WriteLine("{0}, wählen Sie bitte ein Thema", player.Name); foreach (String topic in _questionPool.GetTopics()) { Console.WriteLine(topic); } String choice = Console.ReadLine(); Console.Clear(); QuestionAnswerPair question = _questionPool.GetRandomQuestion(choice); if (question == null) { Console.Clear(); Console.WriteLine("Keine Fragen mehr übrig"); ShowPoints(); isOver = true; break; } Console.WriteLine(question.Question); Console.WriteLine("Richtig oder Falsch"); String rightWrong = Console.ReadLine(); if (rightWrong == "r" || rightWrong == "richtig") { Console.Clear(); Console.WriteLine("Richtig!"); player.Points++; ShowPoints(); } else { Console.Clear(); Console.WriteLine("Falsch, die richtige Antwort wäre: " + question.Answer); ShowPoints(); } Console.ReadKey(); Console.Clear(); } } Console.ReadKey(); Console.Clear(); }