Desperate for help

Building a simple quiz

Page 1 of 1

3 Replies - 509 Views - Last Post: 12 January 2009 - 09:50 PM

#1 ashgotti  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 11-January 09

Desperate for help

Post icon  Posted 11 January 2009 - 01:23 PM

Hello Everyone,

I'm trying to build a simple game with the following components:
  • Randomly display 5 questions out of a pool of 8
  • Do not display the same question twice
  • Track score out of five (Achieved)

It is a simple yes/no quiz. I am able to make a quick of five questions and go through it linearly and tabulate a score at the end. What I need to do is have the five questions display at random from a pool of 8, no repeats, and after five questions, go to the results screen.

I'd really really appreciate some help on this. I can get it to display questions randomly but don't know how to set up the five question event (after the fifth question, go to the results screen) and not repeat questions.

Thank you so much.

Ash

Is This A Good Question/Topic? 0
  • +

Replies To: Desperate for help

#2 BetaWar  Icon User is online

  • #include "soul.h"
  • member icon

Reputation: 1147
  • View blog
  • Posts: 7,134
  • Joined: 07-September 06

Re: Desperate for help

Posted 11 January 2009 - 05:57 PM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 ashgotti  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 11-January 09

Re: Desperate for help

Posted 12 January 2009 - 10:51 AM

View PostBetaWar, on 11 Jan, 2009 - 04:57 PM, said:

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.


Thanks for the quick reply.

I understand that I have to use an Array to randomize the questions and a counter to keep track of the questions so that when counter = 5, go to results page.

I just don't know where to start with an Array. I'm not asking for the code, but a starting point tutorial or guide link. Any direction really.

Thanks again.
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is online

  • #include "soul.h"
  • member icon

Reputation: 1147
  • View blog
  • Posts: 7,134
  • Joined: 07-September 06

Re: Desperate for help

Posted 12 January 2009 - 09:50 PM

Here is a basic way to do it that will probably work for what you need:

1 - Create an array (call it whatever you want, but for the purposes of this I will call it cq)
2 - Create a for loop that selects randomly between question 1 and the last question you have and puts it in atemp variable I will call temp
3 - Loop through the array cq (inside your other forr loop) and check to make sure that temp isn't already a part of the cq array
3a - If it is, then get rid of temp and continue on to the next iteration of the loop
3b - If it isn't add temp to the end of the cq array and continue on to the next iteration of the loop
4 - stop when the cq array's length is what you want (5 in this case)

Hope that makes sense.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1