Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. c# windows application

c# windows application

Scheduled Pinned Locked Moved C#
csharpgame-devxmlhelptutorial
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    naghoumeh14
    wrote on last edited by
    #1

    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

    OriginalGriffO P L 3 Replies Last reply
    0
    • N naghoumeh14

      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

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      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 have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      N 1 Reply Last reply
      0
      • N naghoumeh14

        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

        P Offline
        P Offline
        Programm3r
        wrote on last edited by
        #3

        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: ^_^

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          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.

          N Offline
          N Offline
          naghoumeh14
          wrote on last edited by
          #4

          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?

          OriginalGriffO 1 Reply Last reply
          0
          • N naghoumeh14

            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?

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            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.

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            N 1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              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.

              N Offline
              N Offline
              naghoumeh14
              wrote on last edited by
              #6

              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

              OriginalGriffO 1 Reply Last reply
              0
              • N naghoumeh14

                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

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                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 have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                1 Reply Last reply
                0
                • N naghoumeh14

                  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

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  if you are Using SQL Server 2005 Then simple Select * from QuestionTable Order by NewID() for XML AUTO

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups