I have a project where I want to make a random quiz with random questions and answers. I used a dictionary to do this and I succeeded in making the questions and answers and in displaying a random one.
Now I want to add specific answers per question asked. I figured this should be done by a dictionary also but I don't know how to make this work.
I already made the random generator, the questions and answers (tkey and tvalue)
So now I only need to add a part where you have specific answers per questions and a way to detect if the questions are wrong or right, this can be done by a if and a else statement but I'm not experienced enough to know how to implement all these functions.
This is what I have right now
class Program
{
static public void Main()
{
//maak een dictionary aan
Console.WriteLine("Quiz");
Dictionary<int, string> Questions = new Dictionary<int, string>();
//voeg vragen toe
//key koppelen aan vraag
Questions.Add(11, "Vraag1?");
Questions.Add(12, "Vraag2?");
Questions.Add(13, "Vraag3?");
Questions.Add(14, "Vraag4?");
Questions.Add(15, "Vraag5?");
Dictionary<int, string> answers = new Dictionary<int, string>();
List<int> keylist = new List<int>(); // string naar int converten
keylist = Questions.Keys.ToList();
Random rand = new Random(); //maak random aan
int countKeys = Questions.Keys.Count();
int randomIndex = rand.Next(0, countKeys);
Console.WriteLine(Questions.ElementAt(randomIndex).Key); //geef een random index en de gekoppelde key daaraan
string input = Console.ReadLine();
Console.WriteLine("You answered: " + input);
Console.ReadKey();
}
}
Can someone help me by telling me / helping me make a way to add specific answers to these questions?