Utilising data files with arrays to make a quiz
Author |
Message |
tristanbryce7
|
Posted: Sat Jan 12, 2013 5:39 pm Post subject: Utilising data files with arrays to make a quiz |
|
|
Hello , I Am making a quiz with 3 levels of difficulty and each level having 10 questions each,
i Have an idea to use data files plus arrays to make my code much more efficient, but am stuck on how to do it. What i plan on doing is make a data file for "Easy Level" questions (and both other levels), and on top of that, i plan to make 4 other data files for Easy,(one which would be EasyLevelA, where all of them are the "A" options for the respective questions.
For example "easylevelqtns.t" would be like this
Turing: |
"What is Dr.Who's real name?""Which planet does Dr.Who come from""How old was he when he first came to Earth?"
|
and "easylevelanswerA.t" would be like
Turing: |
"Johnny""Zorbag""13"
|
where Johnny is option A for the question "What is Dr whos real name" and so on, and i plan on doing this for options B,C,D as well.
So what i had in mind was to make an array for each of those so i could read them off the data file i create
Turing: |
var easyQtns : array 1 .. 10 of string
var easyQtns_optA : array 1..10 of string
var easyQtns_optB : array 1..10 of string
var easyQtns_optC : array 1..10 of string
var easyQtns_optD: array 1..10 of string
|
and so on, for each level of difficulty, id make a new data file, and then read them and display them on the screen using Font.Draw like
and so forth, I know I might be a bit unclear as to what i want, and if you don't understand, I can further clarify if you need to, but I was really hoping that i could try this, And if it could be acheived or if there is an even faster way i would love to know about it. Any help would be greatly appreciated ! Thanks! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Panphobia
|
Posted: Sat Jan 12, 2013 6:20 pm Post subject: RE:Utilising data files with arrays to make a quiz |
|
|
Are you asking us to make your code for you, or do you need help with something, here is a good tutorial on data files http://compsci.ca/v3/viewtopic.php?t=12972&highlight=data , and you don't need to have different data files for levels you could have Easy as a start of a record, and then EasyLevelA,B,C as fields with the question and answers under them, and then do the same with medium and hard |
|
|
|
|
|
tristanbryce7
|
Posted: Sat Jan 12, 2013 6:36 pm Post subject: Re: Utilising data files with arrays to make a quiz |
|
|
Nope, i was hopping for a step in the right direction, and yah I figured out something, I'm only using three data files now (one for easy, medium, hard) and each one contains the questions and answers within it . I'm workin on an idea(array within for loop to gather all the data to store them in variables), and tell you guys how it goes if it ever works haha |
|
|
|
|
|
Raknarg
|
Posted: Sat Jan 12, 2013 10:56 pm Post subject: RE:Utilising data files with arrays to make a quiz |
|
|
I'm mobile right now so I can't help yet (too much typing :p), but as a suggestion you could use a single multidimensional array for the options instead of four arrays... Simplifies your life and it's good coding practice in this case |
|
|
|
|
|
|
|