Harasume Posted February 27, 2015 Share Posted February 27, 2015 I need Help!!! I have an assignment due for a 'Guess the State Capital' Game, the details are here http://www.cs.wcupa.edu/rkline/wpeval/program-2.html. I can't get the answer to generate at all! I have no idea what I'm doing. Everything I've got so far is uploaded below. program.php Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/ Share on other sites More sharing options...
ginerjm Posted February 27, 2015 Share Posted February 27, 2015 Homework? Should of gone to class more. Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/#findComment-1506924 Share on other sites More sharing options...
Harasume Posted February 27, 2015 Author Share Posted February 27, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/#findComment-1506944 Share on other sites More sharing options...
ginerjm Posted February 27, 2015 Share Posted February 27, 2015 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. 1 Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/#findComment-1506946 Share on other sites More sharing options...
Barand Posted February 27, 2015 Share Posted February 27, 2015 Homework? Should of gone to class more. Should of! Evidently should have gone to English class more Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/#findComment-1506985 Share on other sites More sharing options...
ginerjm Posted February 27, 2015 Share Posted February 27, 2015 Must be Friday.... Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/#findComment-1506987 Share on other sites More sharing options...
Psycho Posted February 27, 2015 Share Posted February 27, 2015 Should of! Evidently should have gone to English class more Yeah, but he's not asking you to correct his grammar now is he. Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/#findComment-1506988 Share on other sites More sharing options...
ginerjm Posted February 27, 2015 Share Posted February 27, 2015 Ooooh! And the party grows... Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/#findComment-1506989 Share on other sites More sharing options...
Solution Psycho Posted February 27, 2015 Solution Share Posted February 27, 2015 (edited) @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 February 27, 2015 by Psycho Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/#findComment-1506990 Share on other sites More sharing options...
Harasume Posted February 27, 2015 Author Share Posted February 27, 2015 Thank you Guru. That is a big help. Quote Link to comment https://forums.phpfreaks.com/topic/294928-need-help-generating-an-answer-for-a-guessing-game/#findComment-1506998 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.