示例#1
0
        static void AddQuestion()
        {
            Console.WriteLine("Welche Art von Frage wollen Sie hinzufügen?");
            Console.WriteLine("(1) Freitext-Frage");
            Console.WriteLine("(2) Ja/Nein Frage");
            Console.WriteLine("(3) SingleChoice Frage");
            Console.WriteLine("(4) MultipleChoice Frage");
            Console.WriteLine("(5) Schätz Frage");

            string decision = Console.ReadLine();

            Quizelement newQuestion;

            switch (decision)
            {
            case "1":
                newQuestion = new QuizFree();
                break;

            case "2":
                newQuestion = new QuizBinary();
                break;

            case "3":
                newQuestion = new QuizSingle();
                break;

            case "4":
                newQuestion = new QuizMultiple();
                break;

            case "5":
                newQuestion = new QuizGuess();
                break;

            default:
                newQuestion = new QuizGuess();
                break;
            }
            newQuestion.createElement();
            questions.Add(newQuestion);

            json = JsonConvert.SerializeObject(questions, Formatting.Indented);
            File.WriteAllText(filepath, json);
        }
示例#2
0
        static void AddQuestion()
        {
            Console.WriteLine("Welche Art von Frage wollen Sie hinzufügen?");
            Console.WriteLine("(1) Freitext-Frage");
            Console.WriteLine("(2) Ja/Nein Frage");
            Console.WriteLine("(3) SingleChoice Frage");
            Console.WriteLine("(4) MultipleChoice Frage");
            Console.WriteLine("(5) Schätz Frage");

            string decision = Console.ReadLine();

            switch (decision)
            {
            case "1":
                Quizelement freeText = new QuizFree();
                freeText.createElement();
                questions.Add(freeText);
                break;

            case "2":
                Quizelement binaryQuestion = new QuizBinary();
                binaryQuestion.createElement();
                questions.Add(binaryQuestion);
                break;

            case "3":
                Quizelement singleChoice = new QuizSingle();
                singleChoice.createElement();
                questions.Add(singleChoice);
                break;

            case "4":
                Quizelement multiChoice = new QuizMultiple();
                multiChoice.createElement();
                questions.Add(multiChoice);
                break;

            case "5":
                Quizelement guessQuestion = new QuizGuess();
                guessQuestion.createElement();
                questions.Add(guessQuestion);
                break;
            }
        }