c# windows application
-
i would like to know if anyone can help me to construct a window application to make a small MCQ (multiple chooice question) game.. i have to do this project for university and i don't know where or how to start.... plz help.. we need to use an XML file and to pick questions randomly from this file and we have to put the 4 possibilities randomly in 4 buttons and the user will then pick the answer .. so help me if you can
-
i would like to know if anyone can help me to construct a window application to make a small MCQ (multiple chooice question) game.. i have to do this project for university and i don't know where or how to start.... plz help.. we need to use an XML file and to pick questions randomly from this file and we have to put the 4 possibilities randomly in 4 buttons and the user will then pick the answer .. so help me if you can
You need to do several things: 1) Create your XMl file full of questions, and four answers per question. 2) Look at XMLReader in the documentation 3) Look at Random in the documentation. XMLReader isn't difficult: the simplest case is:
XmlTextReader xmlReader = new XmlTextReader("questions.xml");
Console.WriteLine(xmlReader.AttributeCount);
while(xmlReader.Read())
{
Console.WriteLine(xmlReader.Value);
}It can do loads more than that, but it's a start. Random is also easy:
Random rnd = new Random;
for (int i = 0; i < 10; i++)
{
Console.WriteLine(rnd.Next(4));
}Will print 10 random numbers between 0 and 3 inclusive.
All those who believe in psycho kinesis, raise my hand.
-
i would like to know if anyone can help me to construct a window application to make a small MCQ (multiple chooice question) game.. i have to do this project for university and i don't know where or how to start.... plz help.. we need to use an XML file and to pick questions randomly from this file and we have to put the 4 possibilities randomly in 4 buttons and the user will then pick the answer .. so help me if you can
Hi, I don't know whether I can help you construct the application, but I can provide you with a starting point. Here are a couple of link that can get you started. C# and XML[^] Adding CheckBox Controls to a Form from code[^] I would say that the construction of your XML file is the secret. Do that correctly and the rest of the application will be a breeze! Kind regards,
The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
-
You need to do several things: 1) Create your XMl file full of questions, and four answers per question. 2) Look at XMLReader in the documentation 3) Look at Random in the documentation. XMLReader isn't difficult: the simplest case is:
XmlTextReader xmlReader = new XmlTextReader("questions.xml");
Console.WriteLine(xmlReader.AttributeCount);
while(xmlReader.Read())
{
Console.WriteLine(xmlReader.Value);
}It can do loads more than that, but it's a start. Random is also easy:
Random rnd = new Random;
for (int i = 0; i < 10; i++)
{
Console.WriteLine(rnd.Next(4));
}Will print 10 random numbers between 0 and 3 inclusive.
All those who believe in psycho kinesis, raise my hand.
thank you vey much... but there's something i want to know about... let's suppose i wrote my xml file containing 100 questions so i have to pick randomly 5 questions... what should i do to be sure that the same question isn't going to be repeated twice?
-
thank you vey much... but there's something i want to know about... let's suppose i wrote my xml file containing 100 questions so i have to pick randomly 5 questions... what should i do to be sure that the same question isn't going to be repeated twice?
You will need to keep a record of which questions have been picked allready, and generate a new random number. Or (more advanced): When you read in your XML file, create a class that holds a question, and its possible answers. Store all these questions in a List<myClass> (which is easy)
List<myClass> questions = new List<myClass>;
myClass question = new myClass(ReadQuestionFromXML());
questions.Add(question);Now when you want a new question, use Random with the number of questions left as the upper limit, then remove the question from the list and display it. This is difficult to explain, as I don't want to give you the answer - you won't learn anything if I do - but it honestly is not as difficult as you think! Just do it in stages: Create the XML Read the XML Create the list Use the list. You can probably also break each of these stages down into smaller tasks, and implement them and test before moving on to the next.
All those who believe in psycho kinesis, raise my hand.
-
You will need to keep a record of which questions have been picked allready, and generate a new random number. Or (more advanced): When you read in your XML file, create a class that holds a question, and its possible answers. Store all these questions in a List<myClass> (which is easy)
List<myClass> questions = new List<myClass>;
myClass question = new myClass(ReadQuestionFromXML());
questions.Add(question);Now when you want a new question, use Random with the number of questions left as the upper limit, then remove the question from the list and display it. This is difficult to explain, as I don't want to give you the answer - you won't learn anything if I do - but it honestly is not as difficult as you think! Just do it in stages: Create the XML Read the XML Create the list Use the list. You can probably also break each of these stages down into smaller tasks, and implement them and test before moving on to the next.
All those who believe in psycho kinesis, raise my hand.
okay i'm starting to get.. so all i have to do is to work in small steps... i really want to thank you for helping me ...so i'll start my program and if i have any question i will be thankfull if you could anwser me.. nagham
-
okay i'm starting to get.. so all i have to do is to work in small steps... i really want to thank you for helping me ...so i'll start my program and if i have any question i will be thankfull if you could anwser me.. nagham
Yes, thats the idea - do it in small steps! I'll answer if I can - and so will everyone else. :laugh:
All those who believe in psycho kinesis, raise my hand.
-
i would like to know if anyone can help me to construct a window application to make a small MCQ (multiple chooice question) game.. i have to do this project for university and i don't know where or how to start.... plz help.. we need to use an XML file and to pick questions randomly from this file and we have to put the 4 possibilities randomly in 4 buttons and the user will then pick the answer .. so help me if you can