Creating a Visual C# questionare type application #HELP

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 1474 Views - Last Post: 28 February 2012 - 08:47 AM Rate Topic: -----

#1 gamergrl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-February 12

Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 03:33 PM

Hello

I have only been coding for a few weeks with visual studio and I need a Bit of help xD

I am trying to produce a application that tells the user what type of holiday they are suited to.

It will have multiple chose questions and at the end it will show what holiday suits them the most..

I am not sure how to go about this or if I need a database... could you please PLEASE advice because I am stuck. :(



so for example 5 questions asking questions such as
1. I want a ____ Holiday :
A. calm
B. fun
C. Family

and then at the end it will show the type they want.... I hope I have explained it well

Thank you for any help :)

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a Visual C# questionare type application #HELP

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9393
  • View blog
  • Posts: 35,278
  • Joined: 12-June 08

Re: Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 03:36 PM

Where are you stuck at? The database bit? Setting up the GUI? Creating a project/solution?
Was This Post Helpful? 1
  • +
  • -

#3 gamergrl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-February 12

Re: Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 03:42 PM

Ahh I can create the GUI very easily. I am just not sure how to code it all to work you see :(.. or If I should create a database or just use labels.... if I was to use a database Im not sure how I would get the information from there to the c# project.. I would be using Microsoft access.

This is just a little project that I have set for myself for 2 weeks.. any help would be greatly received
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9393
  • View blog
  • Posts: 35,278
  • Joined: 12-June 08

Re: Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 03:50 PM

So yes.. you'll need a place to house your data (I doubt you are going to hard code it, right?!). That means a database, a flat file, *SOMETHING*. That's up to you.

Then you need to read in the data.. depending on your means of holding it that could be just a 'stream reader' , for a file, or a few sqlcommand objects.

Personally, after I have my rows of data loaded, I would show a label(question) and then some way of recording the answer.. I don't know if that's an array of some sort, some value totaled up, etc..
Was This Post Helpful? 1
  • +
  • -

#5 gamergrl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-February 12

Re: Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 04:00 PM

Ok thank you. I will be creating the GUI tomorrow and sorting out the questions etc... then Ill get on to the database etc.. thanks for your help so far :)
Was This Post Helpful? 0
  • +
  • -

#6 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2268
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 04:10 PM

You're doing things backwards.
  • GUI
  • Data Representation


Stop. How can you write the GUI when you don't know what you're going to need?!
  • Data Representation
  • GUI

Think about how the data is going to represented conceptually.

This post has been edited by AdamSpeight2008: 01 February 2012 - 04:10 PM

Was This Post Helpful? 2
  • +
  • -

#7 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5583
  • View blog
  • Posts: 11,943
  • Joined: 02-June 10

Re: Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 04:34 PM

View PostAdamSpeight2008, on 01 February 2012 - 05:10 PM, said:

Stop. How can you write the GUI when you don't know what you're going to need?!


THANK YOU! You beat me to it, but that's good as long as someone got it out there.

Whether this is homework or not is beside the point, this article might help you with thinking it through BEFORE banging on the keyboard.
This is the 'Help me with my homework' article you wanted.
Was This Post Helpful? 1
  • +
  • -

#8 gamergrl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-February 12

Re: Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 04:54 PM

It is how I have always done it.. get the basic layout right (titles, textboxes, buttons pages etc) then write the code after.. remember I am using visual studio 2010 :). In other languages like java etc it would be different..

in terms of the database you are right.. I need to do that 1st before I do anything else

Or am I wrong.. I am self teaching myself here and I have just begun visual c# :)
Was This Post Helpful? 0
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2268
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 04:55 PM

In doesn't matter what programming language you use, what matters is the process you to analyse the problem-space.

Think it about the problem-space on conceptual (or in abstract terms) level first. It helps to write it out in a set of questions, that you answer.

What is a Quiz? A series of Questions.
Quiz::= Question+


What is multiple choice question? It is Question followed by a series of choices, which typical has at least one answer.
MultipleChoiceQuestion::= Question + Choice+ + Answer+



Having done this, you'll find that you've created a grammar, that describes (and captures) your problem space.
MCQuestion::= Question + Choice+ + Answer
    MCQuiz::= MCQuestion+
  Question::= ...
    Choice::= ...
    Answer::= ...


Now it is relatively simple to translate this into code, or analyse to find problems.

This post has been edited by AdamSpeight2008: 01 February 2012 - 05:10 PM

Was This Post Helpful? 4
  • +
  • -

#10 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5583
  • View blog
  • Posts: 11,943
  • Joined: 02-June 10

Re: Creating a Visual C# questionare type application #HELP

Posted 01 February 2012 - 05:31 PM

View Postgamergrl, on 01 February 2012 - 05:54 PM, said:

It is how I have always done it.. get the basic layout right (titles, textboxes, buttons pages etc) then write the code after.. remember I am using visual studio 2010


You're writing in the C# forum... Of course you are writing in Visual Studio. We all are. Its not like Apple's Xcode is an option. There might be a couple other 3rd party IDE's for C#, but why would you when the MS one is FREE for the basic edition?

GUI and logic/data are supposed to be separate. Period. For example, you can't serialize a GUI control. That's why you make a class to hold your data.

The GUI has one purpose in life: Provide a way of interacting with your data. If you don't know what your data is, then how do you know how to interact with it? If you are using a database you might have a DataGrid. Maybe you have a simple list, so you use a ListView or ListBox.

Sometimes you have to build both together a little. I often have to build a temporary little utilitarian form for the purpose of making the data, or making some test data. I mean it has to come in someplace, right? But that tool is never the user GUI that will be released. Its just an R&D tool, quick and often ugly.

Ideally your data is so separated from your GUI that you can make as many different views into the data as you want, EASILY. One form for grunt workers. One for supervisors with additional information. One for the end-use customer. But all of the work is done in the classes not the GUI.

Separating data from GUI - PLUS - serializing the data to XML
Was This Post Helpful? 4
  • +
  • -

#11 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4531
  • View blog
  • Posts: 7,903
  • Joined: 08-June 10

Re: Creating a Visual C# questionare type application #HELP

Posted 02 February 2012 - 08:07 AM

Not to beat a dead horse, but I'm also going to have to throw my hat in on designing your logic before your GUI. The GUI serves as a vehicle for the data, not the other way around. Therefore, it's best to put together a good datastructure that works no matter what GUI you use, then design a GUI around that.

That's why I frequently work out my logic in a console application. It lets you get the data right, the logic right, without worrying about getting display right. Then, once that's handled, then you can begin "dressing it up."

But doing the GUI first is kinda like making the dress without measuring the bride. You'll get a pretty dress, but it probably won't fit, and you'll either have to change the dress or make the bride lose weight, both of which are harder than just making it right the first time.
Was This Post Helpful? 3
  • +
  • -

#12 peace_fixation  Icon User is offline

  • D.I.C Head

Reputation: 46
  • View blog
  • Posts: 198
  • Joined: 01-November 11

Re: Creating a Visual C# questionare type application #HELP

Posted 03 February 2012 - 07:20 AM

I'm just starting C# myself and have set myself a project to gather data about the Windows environment and display it nicely. I'm still working on the logic and printing my output to the console. My class looks something like this:

public class WinEnv
{
  public string getWindowsVersion()    { /* logic to obtain Windows Version */ }
  public string getMSOfficeVersion()   { /* logic ... */ }
  public string getMSExchangeVersion() { /* logic ... */ }
  public string getDiskUsage()         { /* logic ... */ }
  public string getLocalAdminGroup()   { /* logic ... */ }
  public string getTempFolderUsage()   { /* logic ... */ }

  public static void main()
  {
    WinEnv we = new WinEnv();
    Console.WriteLine(we.getWindowsVersion());
    Console.WriteLine(we.getMSOfficeVersion);
    Console.WriteLine(we.getMSExchangeVersion);
    // etc
  }
}


At this point I have all the data I need in string format and I can display it in anyway I need to. I plan to write a GUI now and have a few options available for which data is displayed.

This post has been edited by peace_fixation: 03 February 2012 - 07:22 AM

Was This Post Helpful? 0
  • +
  • -

#13 innuendoreplay  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 62
  • Joined: 01-October 11

Re: Creating a Visual C# questionare type application #HELP

Posted 03 February 2012 - 10:59 AM

Hey!, you can develop the application in infinite ways....but a simple way is doing with an array in which you save the input of the user, and at end you relationate thats answers with a predefined matrix (2 x n). For example:
String answers[] = new String[5];

Console.WriteLine("I want___Holiday: ");Console.ReadLine();
answers[0] = Console.ReadLine();

Was This Post Helpful? 0
  • +
  • -

#14 mrburnttoast  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 28-December 11

Re: Creating a Visual C# questionare type application #HELP

Posted 10 February 2012 - 10:23 PM

This question could be answered in two ways depending on whether you are just trying to teach yourself the language and some basic programming concepts or trying to make a product that is distributed to other people in some fashion. If it's the former and you are relatively new to programming, start simple. Just drag and drop the controls you want to use onto the form and then code your logic into the click event of the submit button on your form. Or better yet, create a function that is called by the form. If you aren't going to change the questions and answers and you aren't going to store the user responses, then don't worry about a database. You can always rework some aspects of the program later.
Was This Post Helpful? 0
  • +
  • -

#15 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2268
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Creating a Visual C# questionare type application #HELP

Posted 11 February 2012 - 12:39 AM

mrburnttoast
It doesn't matter how pretty the GUI is, if the underlying code doesn't work.

Function over (GUI)Form every time.

Quote

Just drag and drop the controls you want to use onto the form and then code your logic into the click event of the submit button on your form.


From my experience a lot don't progress any further, stuck in thinking in terms of Controls because that only what they see in the toolbox. They just stick everything in the UI Layer, everything is a Control, or everything inside Events. The leads to producing ram-shackled bug-ridden code.

Always start by think about the problem first. Just because it's going to be code later does stop you from using pencil and paper in the development stage!
What are the inputs?
What are the outputs?
What transformations are needed?
What are the encapsulations going to be? (Interfaces, Structures and Classes)
Is there any relationships that can exploited? (Inheritance / Generics)?

Then begin to think about the code.

The 3 basic layers (in bold) are;-
Interface Layer
The Data Layer
The Object Encapsulation Layer
The Business Logic Layer
The UI Layer
I personally think in terms of 2 extra layers (in italics).

What can separated out into code libraries?
Interfaces typically separated out.

Write the core / kernel code for the problem in an GUI agnostic way. Eg it doesn't know about the UI, it just take input and produce output. Example: Conway's Game Of Life Challenge

Then write the UI, it could be a Console or a window.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2