[2008] - VB - Application To Decide Outcome
Hi All,
I've been asked to write an application that will evaluate a user's answers and decide on an outcome. The question's themselves will have the standard Yes / No as responses.
I was thinking of storing the questions in a DB but I am not quite sure ATM if this is the best path to take.
For example, if a user selects "Yes" to Q1, they are taken to Q3. If no is selected, they are taken to Q2. Upon answering to many NO's, the application will inform them that they can not continue. Any suggestions / links would be much appreciated.
Re: [2008] - VB - Application To Decide Outcome
If the questions aren't going to change regularly then you'd probably want to hard-code that. Choosing a course based on the outcome would be more difficult if the questions are coming from elsewhere. I guess you could have a column containing the ID of the next question they answer Yes and another for the next question if they answer No. That could work.
Re: [2008] - VB - Application To Decide Outcome
Thanks for the suggestion :thumb: . The questions themselves will always remain static. I'm now stuck at how to increment to the correct question based on the selection. Any suggestions?
Re: [2008] - VB - Application To Decide Outcome
The Question table in the database would have ID, Text, YesID and NoID columns. You would start by getting the Question with ID 1 and display its Text. If the user answered Yes you would get its YesID value and if the user answered No you would get its NoID value. You would then get the next question by getting the Question with the ID you got from the user's response. That would continue until the you get a response from the user that doesn't have a corresponding ID. At that point you can do whatever you deem to be appropriate.
Re: [2008] - VB - Application To Decide Outcome
I dont understand why you are going down the database route when you have just said that the questions will be static. Why not just hard code them?
Re: [2008] - VB - Application To Decide Outcome
Even hardcoded I would follow the outline that JM laid out. However, if it was hardcoded, I would make up a small class that has the members that he listed. You would then have a List of that class. Each class would keep a member that would hold the index of the No question, and the index of the Yes question. You could have a single method that accepted a boolean (True=Yes, False=No), and returned the index of the next question, or returned -1 if the user was an obstinate fool who could not continue. The implementation would be pretty similar.
Re: [2008] - VB - Application To Decide Outcome
Since you are using Visual Studio 2008, it may be beneficial to use Windows Workflow Foundation.
This article may help you decide.
http://msdn.microsoft.com/en-us/library/cc709416.aspx