Computer Science Canada How to make A question and answer game? |
Author: | bc123 [ Thu Oct 15, 2009 2:52 pm ] |
Post subject: | How to make A question and answer game? |
Hey i wanted to do something when i make it say What is my name and then some one has to answer corectly to say corect and if wrong then say incorrect. I am totaly new to turing im starting to learn in school and i want to atleast kno this. All i kno is like % blablabla is comments and put and get but im not too sure like how to use them like with int and everything plzz help! and 1 more thing i wanted to kno how to get back to main like screen so i dont have to close the turing thing and click run again. TY ![]() also i dont want some 1 to give me the code and say here you go did it for you... if you can plz try to explain like i tried to do %Brandon % october 15 2009 var 1 = int put "Hello! " put "Answer the questions corectly " get im totaly lost and dont think this makes sense whatsoever so plz help! |
Author: | andrew. [ Thu Oct 15, 2009 3:06 pm ] |
Post subject: | RE:How to make A question and answer game? |
Okay, well here is a summary of different functions: put - you can write stuff to the screen get - you can get input from the user (this includes strings, ints, etc.) int - an integer type. It holds only non-decimal numbers loop - you can have certain parts of your code loop around until some kind of condition is met (in your case, they guess the right age) If you need more help with the functions, look them up in the Turing help (press F10 in Turing) and then write out (in plain English) every step it will take to do this. Then you can easily turn that into Turing code. |
Author: | bc123 [ Thu Oct 15, 2009 3:10 pm ] |
Post subject: | RE:How to make A question and answer game? |
still confused :S sorry |
Author: | S_Grimm [ Thu Oct 15, 2009 3:13 pm ] |
Post subject: | RE:How to make A question and answer game? |
if (statement) else (statement) those two will enable you to make a Q&A game |
Author: | bc123 [ Thu Oct 15, 2009 3:17 pm ] |
Post subject: | RE:How to make A question and answer game? |
what exactly you mean by statements? var? |
Author: | S_Grimm [ Thu Oct 15, 2009 3:38 pm ] | ||
Post subject: | Re: How to make A question and answer game? | ||
for example
|
Author: | ecookman [ Thu Oct 15, 2009 3:46 pm ] | ||
Post subject: | Re: How to make A question and answer game? | ||
statements are lines...in lack of a better term...do something or declare something var creates a variable anything after var is the variable the : says that that variable is this...either a string (text) or Boolean (true, false 1, 0), or a integer. Basically you need a bunch of if, else, and get statements. Here is a example. Please tell me how it works and fill in the blanks (remove the _____). (comment the code)
|
Author: | bc123 [ Thu Oct 15, 2009 3:51 pm ] |
Post subject: | RE:How to make A question and answer game? |
TY SO MUCH wut does locate do? |
Author: | ecookman [ Thu Oct 15, 2009 3:53 pm ] |
Post subject: | Re: RE:How to make A question and answer game? |
bc123 @ Thu Oct 15, 2009 3:51 pm wrote: TY SO MUCH wut does locate do?
notice how the text isn't at thr right side of the page and a little down locate tells the text where to be put also could you tell me how the code works so you are not copying it. |
Author: | bc123 [ Thu Oct 15, 2009 3:58 pm ] |
Post subject: | RE:How to make A question and answer game? |
ok i re typed it put "Question and Answer Game" var n : string put "What is my name?" get n if n = "brandon" then put "correct" else put "wrong" end if put is puting out like a comment but visual (no code_ the variable im not too sure about also nto too sure about the string from what i understand get n is getting the variable and saying if n = my name theh (type correct of w/e) else meaning if it is sumthing else type "error" and the end if is ending the if statement |
Author: | bc123 [ Thu Oct 15, 2009 4:00 pm ] |
Post subject: | RE:How to make A question and answer game? |
wait does the string replace puting int? |
Author: | S_Grimm [ Thu Oct 15, 2009 4:01 pm ] | ||
Post subject: | RE:How to make A question and answer game? | ||
yes, string replaces int |
Author: | bc123 [ Thu Oct 15, 2009 4:03 pm ] | ||
Post subject: | Re: How to make A question and answer game? | ||
AV @ Thu Oct 15, 2009 3:38 pm wrote: for example
i couldnt get this to work it sayd 2 errors |
Author: | S_Grimm [ Thu Oct 15, 2009 4:05 pm ] | ||||||
Post subject: | RE:How to make A question and answer game? | ||||||
well, I havent coded turing in almost forever so i forgot the following:
not
also that is not a complete program. remove the
|
Author: | bc123 [ Thu Oct 15, 2009 4:06 pm ] |
Post subject: | RE:How to make A question and answer game? |
ok i amd goin to make a quick game hopefully it will workout and ill send to you if youd like but theres gunna be about 20 questions XD or 15 |
Author: | ecookman [ Thu Oct 15, 2009 4:09 pm ] | ||
Post subject: | RE:How to make A question and answer game? | ||
alright After var you can put anything you want as if it is not a turing function like get or put. what follows var is something that you can control what it is. I could say var (says a vairible is being made) chips (name of the variable) : string (strings are text int is numbers) chips := 1 (this says that the variable chips is equal to one) put chips (this says print the variable to the screen which all you will see is a 1 so that looks like
the get statement after a line pauses the program and waits for user input. after you hit enter, what you typed is saved ot the variable for later use (the variable is saved untill you close the run window) |
Author: | bc123 [ Thu Oct 15, 2009 5:06 pm ] |
Post subject: | Re: How to make A question and answer game? |
download the notpad file and paste into turing hope i posted it right |
Author: | bc123 [ Thu Oct 15, 2009 5:12 pm ] | ||
Post subject: | Re: RE:How to make A question and answer game? | ||
ecookman @ Thu Oct 15, 2009 4:09 pm wrote: alright
oooo i see ty im starting to catch on. very helpful! um do u think you have an idea of how i would make this
After var you can put anything you want as if it is not a turing function like get or put. what follows var is something that you can control what it is. I could say var (says a vairible is being made) chips (name of the variable) : string (strings are text int is numbers) chips := 1 (this says that the variable chips is equal to one) put chips (this says print the variable to the screen which all you will see is a 1 so that looks like
the get statement after a line pauses the program and waits for user input. after you hit enter, what you typed is saved ot the variable for later use (the variable is saved untill you close the run window) my teacher wants us to make a stat thing for any sport player, i dhose sidney crosby(not sure why) then he wants use to enter goals assists total points and then it will all display at the end so he wants it to say number of goals (then i enter it here) number of assists (enter it here) total points: (enter here) process sidney crosby ##goals, ## assists ## points i have no idea on what to do ![]() |
Author: | ecookman [ Thu Oct 15, 2009 5:39 pm ] | ||
Post subject: | RE:How to make A question and answer game? | ||
step one...make your variables (these are numbers hint hint) you would use the put statement to ask the questions Then a following get statement Then, if he hasn't told you how to do this, it isn't intuitive. if you put a variable after the put statement without quotes. the variable will display what it is holding. look at the code i made with chips...look at the put statement. Notice in turing how chips is blue...the same color as the variable. Also when you run the program you see a 1 not chips???
what you will want to do is display the variables between text put "he has", goalVar, "goals", assistVar, "assists", pointsVar, "points" goalVar, assistVar and pointsVar are all variables like chips in this case. When displaying a variable or anything else within text you need to put a comma before and after anything that isn't in quotes. (that is just so turing knows what it is) If you don't you will get a error. There is a long explanation behind it....but that is the general reason. |
Author: | bc123 [ Thu Oct 15, 2009 5:44 pm ] | ||
Post subject: | Re: RE:How to make A question and answer game? | ||
ecookman @ Thu Oct 15, 2009 5:39 pm wrote: step one...make your variables (these are numbers hint hint)
you would use the put statement to ask the questions Then a following get statement Then, if he hasn't told you how to do this, it isn't intuitive. if you put a variable after the put statement without quotes. the variable will display what it is holding. look at the code i made with chips...look at the put statement. Notice in turing how chips is blue...the same color as the variable. Also when you run the program you see a 1 not chips???
what you will want to do is display the variables between text put "he has", goalVar, "goals", assistVar, "assists", pointsVar, "points" goalVar, assistVar and pointsVar are all variables like chips in this case. When displaying a variable or anything else within text you need to put a comma before and after anything that isn't in quotes. (that is just so turing knows what it is) If you don't you will get a error. There is a long explanation behind it....but that is the general reason. how is this isnt like what u said but i guess it kinda works locate (1,20) put "Sidney Crosby's 2009-2010 current stats" put "Please type in Sidney Crosby and hit enter" put "please use proper spelling(use UNDERSCORE as space and capitals)" var i : string get i if i = "Sidney_Crosby" then put "Number: 87" put "Height: 5' 11" put "Weight: 200" put "Shoots: Left" put "Born: Aug 7, 1987 (Age 22) " put "Birthplace: Cole Harbour, NS, Canada " put "Goals:4" put "Assists:1" put "+/-:2" else put "error" end if |
Author: | ecookman [ Thu Oct 15, 2009 5:52 pm ] |
Post subject: | RE:How to make A question and answer game? |
good job. Thats how you code! Just 2 things. you can have spaces in a get statement...meaning the _ is unnecessary you can use a space. also If you want....you don't need the else statement and error. The else statement waits form anything that happens that doesn't follow the rules set above. (your if statement) you can just remove it. BUT if you want to keep it try to make the put statement more decriptive. such as. put "You have failed to input the wrong text. Please restart the program and this time read the directions.) |
Author: | bc123 [ Thu Oct 15, 2009 5:57 pm ] |
Post subject: | RE:How to make A question and answer game? |
good idea . and how do you write your code in code box. and when i try put a space in if statement i get an error no matter what. |
Author: | bc123 [ Thu Oct 15, 2009 5:59 pm ] |
Post subject: | RE:How to make A question and answer game? |
oh and another thing i realized i dunno if you downloaded my trivia thing but even if i enter the wrong answer is still asks next question? would i somehow need to enter a statements on each 1 saying end if its wrong? |
Author: | ecookman [ Thu Oct 15, 2009 6:02 pm ] |
Post subject: | Re: RE:How to make A question and answer game? |
bc123 @ Thu Oct 15, 2009 5:57 pm wrote: good idea . and how do you write your code in code box. and when i try put a space in if statement i get an error no matter what.
sorry mixing up my languages. you can use either (code) put code here (/code) (use square brackets) or below the img button click More Tags and then syntax and between "" put Turing and then when you are done putting your code put [/syntax] or click close tags |
Author: | bc123 [ Thu Oct 15, 2009 6:04 pm ] | ||
Post subject: | Re: How to make A question and answer game? | ||
|
Author: | bc123 [ Thu Oct 15, 2009 6:06 pm ] |
Post subject: | Re: RE:How to make A question and answer game? |
ecookman @ Thu Oct 15, 2009 6:02 pm wrote: bc123 @ Thu Oct 15, 2009 5:57 pm wrote: good idea . and how do you write your code in code box. and when i try put a space in if statement i get an error no matter what.
sorry mixing up my languages. you can use either (code) put code here (/code) (use square brackets) or below the img button click More Tags and then syntax and between "" put Turing and then when you are done putting your code put [/syntax] or click close tags hey do u got xfire or msn we gcan talk through? |
Author: | ecookman [ Thu Oct 15, 2009 6:13 pm ] | ||
Post subject: | RE:How to make A question and answer game? | ||
to stop a program use quit ..... else put "wrong" quit end if like that. if you want you can also close the window first you need to make the winow by putting this at the begginnning of your program. (the first line) var win : int := Window.Open then a Window.Close (win) ("graphics:700;550") then you can do something like this
lol that took me a while to figure that when I first did it. |
Author: | ecookman [ Thu Oct 15, 2009 6:14 pm ] |
Post subject: | RE:How to make A question and answer game? |
and i do have xfire.... click on the xfire icon below my sig line.. add me and ill be a while i gotta walk my dog |
Author: | andrew. [ Thu Oct 15, 2009 7:59 pm ] | ||
Post subject: | RE:How to make A question and answer game? | ||
You shouldn't use quit. If anything, use exit in a loop. If there is no loop, you don't need quit. Turing does things in order (does it line-by-line). When there are no more lines left, it will automatically stop. e.g.
After it does that last line, it will exit automatically. The window will not close though, it will say finished for the title. Also, I hope you noticed that after I put "get name" I added a ": *". Basically, this says to get everything including spaces. Now you don't have to use underscores, people can type in the full name. |
Author: | ecookman [ Thu Oct 15, 2009 8:02 pm ] |
Post subject: | Re: RE:How to make A question and answer game? |
andrew. @ Thu Oct 15, 2009 7:59 pm wrote: You shouldn't use quit. If anything, use exit in a loop. If there is no loop, you don't need quit. Turing does things in order (does it line-by-line). When there are no more lines left, it will automatically stop.
he wanted it to close if someone made a mistake along the way not just at the end. |
Author: | bc123 [ Thu Oct 15, 2009 8:21 pm ] | ||
Post subject: | Re: RE:How to make A question and answer game? | ||
andrew. @ Thu Oct 15, 2009 7:59 pm wrote: You shouldn't use quit. If anything, use exit in a loop. If there is no loop, you don't need quit. Turing does things in order (does it line-by-line). When there are no more lines left, it will automatically stop.
e.g.
After it does that last line, it will exit automatically. The window will not close though, it will say finished for the title. Also, I hope you noticed that after I put "get name" I added a ": *". Basically, this says to get everything including spaces. Now you don't have to use underscores, people can type in the full name. ok im kinda confused? sorry like i tottaly dont mine using quit because i kno what if does XD |