[nfbcs] trouble creating database for Trivia game

Littlefield, Tyler tyler at tysdomain.com
Sat Mar 18 16:27:47 UTC 2017


You don't need a database, so much as you just need a flat-file. Look up
JSON or xml. A database for questions and answers is a bit overkill.
On 3/17/2017 10:34 PM, Jessica D via nfbcs wrote:
> Hi,
> I’m making a trivia game.
> I’d like to make a database of questions and answers so I don’t have to hand code them.
> 
> Can anyone tell me how ot do this?
> 		
> 
> 
> Here is my source code.
> 
> 
> using System;
> using System.Collections.Generic;
> using System.IO;
> namespace Trivia_game
> {
>     partial class Hello
>     {
> 
>         static void Main()
>         {
>             string intro;
>             string Value;
>             Value = Console.ReadLine();
>             string line;
>             line = Console.ReadLine();
> 
>             Console.WriteLine("Hello, lets start enter the value from the file that will best answer the question");
>             intro =("Welcome to "QuizMasters. Inthis game, you'll answer a series of questions. the rules are simple. answer a question correctly and earn points, answer incorrectly and you'll lose everything.)"Console.ReadLine();
> 
>             StreamReader file = new StreamReader("Trivia game questions.txt");
>             while ((line = file.ReadLine()) != null)
>             {
>                 Console.WriteLine(line);
>                 Console.ReadLine();
>             } }
> 
>         var questions = new List<Question>();
> 
> // Open file containing quiz questions using StreamReader, which allows you to read text from files easily.
> 
>     string line;
>     Question question;
> 
>     // Loop through the lines of the file until there are no more (the ReadLine function return null at this point).
>     // Note that the ReadLine called here only reads question texts (first line of a question), while other calls to ReadLine read the choices.
>                 break;
> public object Questions { get => Questions1; set => Questions1 = value; }
>         public object Questions1 { get => Questions2; set => Questions2 = value; }
>         public object Questions2 { get => Questions3; set => Questions3 = value; }
>         public object Questions3 { get => Questions4; set => Questions4 = value; }
>         public object Questions4 { get => questions; set => questions = value; }
>     }
>         }
>     
>         // Check if none of the choices was marked as correct. If this is the case, we throw an exception and then stop processing.
> 
> 
> Thanks,
> Jessica
> 
> Thanks,
> Jessica
> 
> _______________________________________________
> nfbcs mailing list
> nfbcs at nfbnet.org
> http://nfbnet.org/mailman/listinfo/nfbcs_nfbnet.org
> To unsubscribe, change your list options or get your account info for nfbcs:
> http://nfbnet.org/mailman/options/nfbcs_nfbnet.org/tyler%40tysdomain.com
> 


-- 
Take care,
Ty
Twitter: @sorressean
Web: https://tysdomain.com
Pubkey: https://tysdomain.com/files/pubkey.asc




More information about the NFBCS mailing list