Jump to content

Need Help generating an answer for a guessing game


Harasume
Go to solution Solved by Psycho,

Recommended Posts

I go to every single class, and I take notes. I am absolute rubbish with computers, but it was either take this class or lose my job. I have been trying as hard as I can to understand this stuff, but it is not my area of expertise. So instead of being a judgemental jackass, why don't you actually try and be helpful.

Link to comment
Share on other sites

1 - I don't do homework for those who plead as you have done.

2 - I don't look at attachments for code since I hate taking those risks

3 - I do however look at code that is properly posted (see forum rules) on the forum and which the poster has made clear what is what and where he/she suspects his difficulty lies.

4 - I don't use bad language.

  • Like 1
Link to comment
Share on other sites

  • Solution

@Harasume,

 

I looked at the assignment, but not the attached files. The assignment has some pretty specific requirements that can each be done iteratively. Don't look at the problem as a whole, define the smallest possible functions and tackle those one at a time . So, take one step at a time. If you run into problems, post the code relevant to what you are working on and what you problem is. As you get one thing working move on to the next.

 

Here would be my suggestion:

 

1. Create the form and ensure you can post it

2. Use the two arrays to populate the select list

3. Pick a random entry to generate the question

4. Determine how will "remember" the question and the user's answer when the form is posted

5 Create the logic to increment the wrong answers or determine that the right answer was selected

 

EDIT: The instructions give you the code to pick a random state to use for the quiz

 

$state = $states[ mt_rand(0, count($states)-1) ];

 

You just need to use a session value. If the selected state value in the session exists, then the user already initiated the test. If not, you need to generate the value using the code above

 

if(isset($_SESSION['state']))
{
    //User already started the test, test the posted value to the session value
    //And perform steps to increment counter and show correct message
 
 
    //If answer is correct - unset the session value
}
else
{
    $state = $states[ mt_rand(0, count($states)-1) ];
    $_SESSION['state'] = $state;
}
Edited by Psycho
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.