Computer Science Canada

Total noob here, Need some answers please.

Author:  warman123 [ Sun Oct 15, 2006 10:37 am ]
Post subject:  Total noob here, Need some answers please.

Hello, i am doing a quiz project for school.
Im trying to make it show a new (Page/window) whatever you wanna call it each time you answer a question. But instead it just keeps showing the questions on the same page.

Thanks

Author:  neufelni [ Sun Oct 15, 2006 10:59 am ]
Post subject: 

All you need to do is add a cls between each question. cls will clear the screen.

code:
var answer : string

put "What is the answer? " ..
get answer
cls     
put "What is the next answer? " ..
get answer
cls

Author:  Flikerator [ Sun Oct 15, 2006 11:01 am ]
Post subject: 

In Turing, F10, the help file.
Look up "Window".

You could also clear the page with "cls".

Author:  warman123 [ Sun Oct 15, 2006 11:02 am ]
Post subject: 

Thanks a whole heep Very Happy

Author:  warman123 [ Sun Oct 15, 2006 11:04 am ]
Post subject: 

Another question how do i add a score? Like lets say i have 4 questions and theres 1 answer thats correct, and i have 10 set of 4 questions, and the end i want an overall score.

Author:  warman123 [ Sun Oct 15, 2006 11:06 am ]
Post subject: 

Reason why im asking so much is because i was on a vacation, and missed all the explanations

Author:  TheOneTrueGod [ Sun Oct 15, 2006 11:23 am ]
Post subject: 

[Turing Walkthrough] -- Variables. Also read if statements.

Author:  warman123 [ Sun Oct 15, 2006 11:56 am ]
Post subject: 

hmm.. do not see how to create scores.

Author:  Flikerator [ Sun Oct 15, 2006 12:14 pm ]
Post subject: 

Scores are simply variables. When a condition is met the score goes up [or down]. There is no built in "score system".

Author:  Tony [ Sun Oct 15, 2006 12:19 pm ]
Post subject: 

sure there is!
code:

var score : int := 0
put "Your score is: ", score

score += 1
put "Your score is:", score

Laughing

Author:  warman123 [ Sun Oct 15, 2006 6:20 pm ]
Post subject: 

Ok that works ty but how do i make it realize what answer is correct and what is wrong per question section.

Author:  [Gandalf] [ Sun Oct 15, 2006 6:30 pm ]
Post subject: 

You're basically asking every question you need to build your program one by one. I suggest you instead make use of the Turing Walkthrough which will definately have all the answers you need if you actually try to understand what is written there.

To check conditionals you will need if statements. That's it.

Author:  warman123 [ Sun Oct 15, 2006 6:33 pm ]
Post subject: 

Just answer the last 1 and ill read the rest myself plz lol

Author:  TokenHerbz [ Sun Oct 15, 2006 6:56 pm ]
Post subject: 

To see if a condition is true or false, use an if statment....

code:

    if answer = rightanswer then
        score += 1
    end if


you can implement that yourself.

Author:  warman123 [ Sun Oct 15, 2006 6:58 pm ]
Post subject: 

This does not work... I get errors

Author:  Bobrobyn [ Sun Oct 15, 2006 7:05 pm ]
Post subject: 

I think you're missing the concepts of what is actually happening. You should read:

http://www.compsci.ca/v2/viewtopic.php?t=8808

But specifically, for what you're doing, read:

http://www.compsci.ca/v2/viewtopic.php?t=9634
and
http://www.compsci.ca/v2/viewtopic.php?t=367

Author:  warman123 [ Sun Oct 15, 2006 7:10 pm ]
Post subject: 

Anyways i found another thing, When i do this box, the next set of questions started in the box instead of starting back in the main screen.

code:
winID1 := Window.Open ("graphics:300;200;nobuttonbar;position:top;right")

Window.Select (winID1)
put "Correct Answer Is ", Window.GetSelect, "."

Window.SetActive (winID1)
delay (300)
put "C. Is correct"

View.Update
delay (2000)

cls

Author:  warman123 [ Sun Oct 15, 2006 7:11 pm ]
Post subject: 

And thank you for that link, the last one was perfect Very Happy

Author:  Bobrobyn [ Sun Oct 15, 2006 7:19 pm ]
Post subject: 

If you read BOTH of the tutorials I gave you, you should be able to understand the concepts necessary for your assignment. You won't have to run around grabbing code off the internet...because that just won't work all the time. Trust me, if you want to pass this course, learn the concepts so you can do it on your own. Feel free to ask questions if there is something you don't understand, just don't ask for code for your assignment.

Author:  warman123 [ Sun Oct 15, 2006 7:22 pm ]
Post subject: 

Ok roger that, i got a question about one of my codes then

code:
if "C. Smart" =  "C. Smart" then
var score : int := 1


I also tried
code:
if "c" =  "c" then
var score : int := 1


I dont get any errors but, and the end with using this code
It doesnt add
code:
var score : int := 0
put "Your score is: ", score

score += 10
put "Out of ", score

Author:  wtd [ Sun Oct 15, 2006 7:26 pm ]
Post subject: 

Brackets indicate optional code.

Code following the pattern:

code:
var <insert name> : <insert type> [ = <insert value> ]


Comprises a declaration of a variable. This may only be done once for any given name (until you get into functions and procedures).

Author:  [Gandalf] [ Sun Oct 15, 2006 7:28 pm ]
Post subject: 

warman, here's what you do: Go to the Turing Walkthrough, and read through each tutorial one by one. After you do that, solve your own problem. And avoid double posting while you're at it.

Really, like this you can keep asking hundreds of questions for the next day or so and still not understand what you are doing. In this case it's as simple as you assigning 1 to a new variable instead of adding 1 to your existing variable.

Author:  Bobrobyn [ Sun Oct 15, 2006 7:44 pm ]
Post subject: 

Okay, let's look at this from a conceptual point of view. I hope your teacher taught you that you declare your variables at the beginning of your program. Here's a basic structure which may help you, along with the tuturials:

Declare all your variables that you're going to use throughout your program at the top, if you must come back and declare a new one that you're using, sure, do so.

For your if statements, you must compare your variables with the answer. The variable is what stored what the user inputed. "C. Smart" is always going to = "C. Smart". That is never going to change. Let's look at an example (and no, this code will not be useful for copying and pasting into your program:

code:

var userInput: string

put "Type 'a' or 'b'"
get userInput

if userInput = "a" then
   put "You typed 'a'!"
elsif userInput = "b" then
   put "You typed 'b'!"
else
   put "You have typed something else!"
end if


You see, if I did something like:

code:

if "a" = "a" then
put "You pressed a!"

The problem is that "a" ALWAYS = "a". See the point. I hope this helped. Make sure you read the tutorials that were presented here, too.

Author:  sweetiechic [ Mon Oct 16, 2006 9:56 pm ]
Post subject: 

all you need is a loop and an exit when statement dont you? like

var answer: string
loop
put "What colour is the sky?: "..
get answer
cls
exit when answer = "blue"
end loop

correct me if im wrong, im kind of a newbie too Wink

Author:  TokenHerbz [ Mon Oct 16, 2006 10:26 pm ]
Post subject: 

why would you want to loop each question just to get an answer?

Author:  Bobrobyn [ Mon Oct 16, 2006 11:17 pm ]
Post subject: 

sweetiechic wrote:
all you need is a loop and an exit when statement dont you? like

var answer: string
loop
put "What colour is the sky?: "..
get answer
cls
exit when answer = "blue"
end loop

correct me if im wrong, im kind of a newbie too Wink


If you wanted the user to enter a specific answer before you move on, sure, that would work. However, you don't want to do that in the case of a game, quiz, or something, because then the user will always get the answer right, appearing smarter then they actually are Razz

Author:  Prince Pwn [ Tue Oct 24, 2006 8:14 pm ]
Post subject: 

Make variables:
code:

var question : string
var cnt : int := 0 %sets score to 0


Now ask a question:
code:

loop
put "Is Turing fun?"
get question
cls


Now you check if question is what you want it to be:
code:

%checks if what you typed
if question = "yes" then
cnt += 1
elsif question = "no" then
cnt -= 1
else
put "Please enter yes or no"
end if

put cnt
end loop


Here's all:

code:

var question : string
var cnt : int := 0

loop
    put "Is Turing fun?"
    get question
    cls
    if question = "yes" then
        cnt += 1
    elsif question = "no" then
        cnt -= 1
    else
        put "Please enter yes or no"
    end if
    put cnt
end loop


: