MBrendecke icon

Untitled

MBrendecke | PRO | 11/15/18 01:33:37 AM UTC | 0 ⭐ | 486 👁️ | Never ⏰ | []
C# |

3.95 KB

|

None

|

0 👍

/

0 👎

using System;
 
using static System.Console;
 
namespace Sandbox.Intelligenztest
{
    internal class Program
    {
        private static string ChooseLanguage()
        {
            Clear();
            SetCursorPosition(45, 0);
            ForegroundColor = ConsoleColor.Blue;
            WriteLine("Intelligenztest/Intelligence test");
            SetCursorPosition(5, 2);
            WriteLine("Wählen Sie ihre Sprache/Choose your language");
            SetCursorPosition(5, 3);
            WriteLine("a: Englisch/English");
            SetCursorPosition(5, 4);
            WriteLine("b: Deutsch/German");
            SetCursorPosition(5, 5);
            Write("Sprache/language: ");
            return ReadLine();
        }
 
        private static string[] Quiz(int language)
        {
            string[,] questions =
            {
                { "Continue the sequence: 3-6-9-12-?", "Setze die Folgende Zahlenreihe fort: 3-6-9-12-?" },
                { "What doesn't fit?", "Was passt nicht?" },
                { "Continue the sequence: 2-3-5-8-12-?", "Setze die Folgende Zahlenreihe fort: 2-3-5-8-12-?" },
                { "Continue the sequence: 2-5-11-23-47-?", "Setze die Folgende Zahlenreihe fort: 2-5-11-23-47-?" },
                { "What doesn't fit? 4; 5; 6; 8;", "Was passt nicht? 4; 5; 6; 8;" }
            };
 
            string[,] possibleAnswers =
            {
                { "16", "22", "15", "14", "16", "22", "15", "14" },
                { "Monitor", "Keyboard", "Mouse", "Cat", "Bildschirm", "Tastatur", "Maus", "Katze" },
                { "18", "20", "14", "17", "18", "20", "14", "17" },
                { "18", "20", "14", "17", "18", "20", "14", "17" },
                { "8", "4", "5", "6", "8", "4", "5", "6" }
            };
 
            string[] answers = new string[questions.GetLength(0)];
 
            for (int i = 0; i < questions.GetLength(0); i++)
            {
                int y = 3;
                SetCursorPosition(5, (i * 7) + y++);
                WriteLine($"{(char)('1' + i)}. {questions[i, language]}");
 
                for (int letter = 0; letter < 4; letter++)
                {
                    SetCursorPosition(10, (i * 7) + y++);
                    WriteLine($"{(char)('a' + letter)}: {possibleAnswers[i, (language * 4) + letter]}");
                }
                Write((language == 0) ? "The answer is: " : "Die Antwort ist: ");
                answers[i] = ReadLine();
                SetCursorPosition(5, (i * 7) + ++y);
                WriteLine("===================================================");
            }
 
            return answers;
        }
 
        private static void Main(string[] args)
        {
            int Punkte = 0;
 
            string Sprache = "";
 
            do
            {
                Sprache = ChooseLanguage().Trim().ToLower();
            } while (Sprache != "a" && Sprache != "b");
            Clear();
 
            Quiz(Sprache == "a" ? 0 : 1);
 
            SetCursorPosition(5, 39);
            if (Punkte == 5)
            {
                ForegroundColor = ConsoleColor.Green;
                WriteLine("Sie haben {0} von 5 Punkten erreicht", Punkte);
                SetCursorPosition(5, 40);
                Write("Super Leistung!", Punkte);
 
            }
 
            if (Punkte == 4 || Punkte == 3)
            {
                ForegroundColor = ConsoleColor.Yellow;
                WriteLine("Sie haben {0} von 5 Punkten erreicht", Punkte);
                SetCursorPosition(5, 40);
                Write("Gut gemacht, doch das geht noch besser!", Punkte);
            }
            else if (Punkte < 3)
            {
                ForegroundColor = ConsoleColor.Red;
                WriteLine("Sie haben {0} von 5 Punkten erreicht", Punkte);
                SetCursorPosition(5, 40);
                Write("Schlechte Leistung!", Punkte);
            }
 
            ReadKey();
 
        }
    }
}

Comments