[nfbcs] trouble creating database for Trivia game

Jack Heim john at johnheim.com
Sat Mar 18 15:52:22 UTC 2017


You are probably not going to get complete answers on an email list. You 
are going to have to figure some of this out on your own. I suggest you 
start by googling for tutorials on database access in python. You're 
also going to have to make some design decisions on your own. For 
example, you could import your existing questions into a relational 
database system like sqlite or mysql. Or you could continue to store 
them in a file, which is still a database by the way, just not a 
relational database. If you are going to frequently add/remove 
questions, it might be easier to put them in a relational database and 
write code to allow you to modify the questions. But nobody can make 
these decisions for you.



On 03/18/2017 09:16 AM, Jessica Dail via nfbcs wrote:
> Hi,Right now, my questions are in a file. How can I tell my program to read from this file? What do I need to do in order to fix my errors?
>
> Sent from my iPhone
>
>> On Mar 18, 2017, at 8:52 AM, Chris Nestrud via nfbcs <nfbcs at nfbnet.org> wrote:
>>
>> You could investigate SQLite.
>>
>> https://system.data.sqlite.org/
>>
>> Chris
>>
>>> On Fri, Mar 17, 2017 at 10:34:01PM -0400, 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/ccn%40chrisnestrud.com
>>
>> _______________________________________________
>> 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/jldail13%40gmail.com
>
> _______________________________________________
> 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/john%40johnheim.com
>

-- 
Jack Heim, john at johnheim.com




More information about the NFBCS mailing list