Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Capitals of Canada Quiz
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jessica359




PostPosted: Wed Mar 26, 2008 3:22 pm   Post subject: Capitals of Canada Quiz

Earlier on I posted a Canada Quiz which with people's help I finaly finished but then my teacher told me that we weren't aloud to use loops and I used a For Loop so I had to rechange my program to fit "his" standards. So this s my new problem that I came accross.

First British Columbia shows up and you have to write the capital and so on. We have to display the amount of tries that they have out of 3. After 3 the program moves on to the next province. Which it doesn but when it moves on to Alberta and the person gets it wrong it keeps counting the number of tries left from 4 instead of going back down to 0.

Turing:


setscreen ("graphics:700;500") % Sets the screen to a certain amount of pixels.


proc map
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge) %Loads picture of the Canadian map so it can be used through out the program.
end map

%All the declarations.
var answer : string %the variable for the users answer to the question.
var s : int % Score of the user
s := 0 %Score = 0 depending on the users correct answer.
var c : real := 0

var bname : string %The beaver's name.

var font1 : int %declare font 1 so I can use it anywhere in the program.
font1 := Font.New ("Castellar:18") %Type of font & size of font.
assert font1 > 0 %Makes sure that the program is true, if not program is terminated.

var font2 : int
font2 := Font.New ("Curlz MT:18")
assert font2 > 0

var font3 : int
font3 := Font.New ("Georgia:18")
assert font3 > 0

var font4 : int
font4 := Font.New ("Forte:18")
assert font4 > 0

var font5 : int
font5 := Font.New ("Castellar:35")
assert font5 > 0

var font6 : int
font6 := Font.New ("Georgia:30")
assert font6 > 0

var font7 : int
font7 := Font.New ("Arial Black:30")
assert font7 > 0

var font8 : int
font8 := Font.New ("Arial:14")
assert font8 > 0

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%The "flash" screen. Has loading written in big with an alternation of black and white background with all the Canadian province/territory flags.
proc splash
    Font.Draw ("LOADING", 50, 280, font5, 111) %Font.Draw makes the text you want into a certaon font and size. (Makes it look much better!)
    Pic.ScreenLoad ("quebec flag.jpg", 330, 250, picMerge) %Loads picture of the Flag.
    delay (1000) %Delay's the next flag.
    cls %Clears the screen
    drawfillbox (700, 0, 0, 700, 7) %This is a black box. With every flag there is a white and black background flashing.
    Font.Draw ("LOADING", 50, 280, font5, 55)
    Pic.ScreenLoad ("BC Flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("nova scotia flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 55)
    Pic.ScreenLoad ("Alberta Flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("pei flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 55)
    Pic.ScreenLoad ("saskatchewan flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("newfoundland flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 55)
    Pic.ScreenLoad ("manitoba flag.jpg.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("nunavut flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 55)
    Pic.ScreenLoad ("Ontario Flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("north west territories flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    drawfillbox (700, 0, 0, 700, 7)
    Font.Draw ("LOADING", 50, 280, font5, 55)
    Pic.ScreenLoad ("New brunswick flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
    Font.Draw ("LOADING", 50, 280, font5, 111)
    Pic.ScreenLoad ("yukon flag.jpg", 330, 250, picMerge)
    delay (1000)
    cls
end splash

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%The introduction screen with a set of rules. Canadian flag as the back ground and before starting the actual game you must give mister beaver a name. (kinda lame I know but I couldn't use a GUI so we could click on it.)
proc intro
    Pic.ScreenLoad ("CanadianFlag.jpg", -60, 0, picMerge) %Loads picture of the Canadian Flag.
    Font.Draw ("Are you a TRUE Canadian?", 55, 450, font6, 7)
    delay (1000) % delay for "EH?"
    Font.Draw ("EH?", 550, 450, font7, 7)
    delay (1000) %Delay for sets instrutions.
    Font.Draw ("This is the 'Are you a TRUE Candadian EH?' Quiz", 5, 350, font8, 7)
    Font.Draw ("This quiz is on the capitals of the Canadian Provinces and Territories.", 5, 330, font8, 7)
    Font.Draw ("You have 3 tries for each province/territory. Your score will be displayed at the end.", 5, 310, font8, 7)
    Font.Draw ("Pretty Simple? Good LUCK!", 5, 290, font8, 7)
    Font.Draw ("PS. Turn up the volume!", 5, 250, font8, 7)
    Font.Draw ("Please give a name to mister beaver before starting!", 5, 270, font8, 7)
    Pic.ScreenLoad ("beaver.gif", 50, 40, picMerge) %Loads picture of beaver.
    locatexy (300, 400) %Location for the user's writing.
    get bname %Gets the name of the beaver.
    cls %Clears screen for actual game.
end intro

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Music.PlayFileLoop ("Techno - O Canada.mp3") %Begining of O canada (techno version.
%The actual quiz! Shows the Canadian Map as a background, the question with font.draw ontop, the amount of tries the user has left at the bottom right corner and all accompanied by the National Anthem Techno version ;)
proc bc
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    c := c + 1
    cls

    % British Colombia
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    Font.Draw ("What is the Capital of British Colombia?", 0, 450, font1, 111)
    locatexy (300, 400)     %user enters there answer.
    get answer     %Gets the answer
    cls
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)     %Loads the picture of the Canadian Map as a background.
    if answer = "Victoria" or answer = "victoria" or answer = "VICTORIA" then      % I have them in capitals and lower case just to give the user a wider variety.
        Font.Draw ("WOOT -happy dance-", 400, 250, font2, 79)     %if the answer is correct it puts a happy comment.
        s := s + 1     %if the asnwer is correct one point is given, the program keeps a tally of the points aside to give out a total at the end.
        c := 0
        delay (2000)
        cls
    elsif c = 3 then
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
        Font.Draw ("The answer is Victoria", 300, 400, font2, 55)
        delay (2000)
        cls
    else
        Font.Draw ("YOU ARE SO...NOT RIGHT!", 350, 250, font4, 79)     %If the asnwer is not correct a comment is put for them to try again.
        Font.Draw ("Number of gueses of 3", 420, 10, font2, 38)     %Shows the number of guesses they have left decreasing from 2.
        locatexy (650, 10)     % Locates the amount of tries left.
        put c     % Puts the amount of tries left.
        delay (2000)
        cls
        bc
    end if %ends if statement.
end bc

cls

proc ab
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    c := c + 1
    cls
   
    % Alberta
     Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    Font.Draw ("What is the Capital of Alberta?", 0, 450, font1, 111)
    locatexy (300, 400)
    get answer
    cls
    Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
    if answer = "Edmonton" or answer = "edmonton" or answer = "EDMONTON" then
        Font.Draw ("RIGHTO", 400, 250, font2, 79)
        s := s + 1
        c := 0
        delay (1000)
        cls
    elsif c = 3 then
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
        Font.Draw ("The answer is Edmonton", 300, 400, font2, 55)
        delay (2000)
        cls
    else
        Font.Draw ("hahaha... no", 350, 250, font4, 79)
        Font.Draw ("Number of gueses left", 420, 10, font2, 38)
        locatexy (650, 10)
        put c
        delay(2000)
        cls
        ab
    end if
end ab



splash
intro
bc
ab



I would as someone else in my class but they aren't that far yet.
Thanks Smile
Jess
Sponsor
Sponsor
Sponsor
sponsor
Mackie




PostPosted: Wed Mar 26, 2008 3:25 pm   Post subject: RE:Capitals of Canada Quiz

A few things... First off your teacher should be glad you went ahead. Secondly you should really use better variable names. I can't try your program though, you need to package the images with the program.
Jessica359




PostPosted: Wed Mar 26, 2008 3:57 pm   Post subject: RE:Capitals of Canada Quiz

you can just take the images and sound out its just for decaration. Everything else works fine its just the count (variable "c") that won't start over after you change question. It keeps counting from te last question instead of starting over.
Sean




PostPosted: Wed Mar 26, 2008 3:57 pm   Post subject: Re: Capitals of Canada Quiz

You have c, being the chances they took.

You'll want an if statement to check what c is to do the next thing..

Turing:

if c = 3 and s = 0 then
%Your Next Map
end if


If they keep getting wrong, you will want it to check for another interval of 3 every other map. Got it?

And if your teacher doesn't allow for-loops because you are ahead, then tell them off and do it anyways.
Tony




PostPosted: Wed Mar 26, 2008 4:13 pm   Post subject: Re: Capitals of Canada Quiz

Sean @ Wed Mar 26, 2008 3:57 pm wrote:
you will want it to check for another interval of 3 every other map.

That wouldn't work because if I have c == 9, you can't know if I made 3 mistakes on 3 questions or all 9 on the 3rd. Besides, that's not what the question asks. The counter is supposed to start over from 0, so you need to set c to be 0 before starting each question.

Also, c is a pretty bad variable name.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sean




PostPosted: Wed Mar 26, 2008 4:21 pm   Post subject: Re: Capitals of Canada Quiz

Ah, re-read the question and saw my mistake.

You can still use the if statement from above, but add in c := 0 inside the statement.

And then each question will check for a 3 counter.

Turing:

if c = 3 and s = 0 then
c := 0
%Next Flag Question
end if
Insectoid




PostPosted: Wed Mar 26, 2008 5:34 pm   Post subject: RE:Capitals of Canada Quiz

I guess its a good thing my teacher spent 3 days doing 'proper naming of variables, constants, etc.'?

1 letter names are BAD! It makes it confusing for you if you ever leave this project and come back to it later, and difficult for these good people to help you. looking at the code, I don't even know what var : c is, except that it's a number!
Sean




PostPosted: Wed Mar 26, 2008 5:40 pm   Post subject: Re: Capitals of Canada Quiz

Well, your variables are these..

Turing:

var answer : string %the variable for the users answer to the question.
var s : int % Score of the user
s := 0 %Score = 0 depending on the users correct answer.
var c : real := 0
var bname : string %The beaver's name.


You have one variable that is understandable, which is Answer, the others aren't.

You should change your variables to this so you can remember what they are for...

Turing:

var answer, beaver_name : string
var score : int := 0
var chances : real := 0


Also, you can click on the beaver without using GUI, look up Mouse.Where
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Wed Mar 26, 2008 8:13 pm   Post subject: RE:Capitals of Canada Quiz

I'm surprised no one has noticed this yet, but what's with that big honking loading procedure? If I had to sit through that, I might have to off myself. Not only does it not take that long to load images, but it's entirely pointless. Don't make your user sit through something they don't have to.
Tony




PostPosted: Wed Mar 26, 2008 9:56 pm   Post subject: Re: RE:Capitals of Canada Quiz

Sean @ Wed Mar 26, 2008 5:40 pm wrote:
You have one variable that is understandable, which is Answer

Actually even that is ambiguous. It could be (and as a comment suggested) a placeholder for user's answer, but taken out of context (such as when only a part of the code is examined), it could be thought of as the answer we are looking for. A better name would be user_response

Clayton @ Wed Mar 26, 2008 8:13 pm wrote:
I'm surprised no one has noticed this yet...

I don't actually run any Turing source anymore.. until someone buys me a copy of VM Fusion. I just read it now, so such parts are skipped over.

also Re: loading bars @ /blog
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Jessica359




PostPosted: Thu Mar 27, 2008 7:41 am   Post subject: RE:Capitals of Canada Quiz

Wow, um ok thanks guys with your help I got it to work.
This was all I was missing
code:

    elsif chance = 3 then
        cls
        Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
        Font.Draw ("The answer is Edmonton", 300, 400, font2, 55)
        delay (2000)
        chance := 0
        cls


chance =0 to tell it to restart over again.
YAY Very Happy

Also thanks for the advice on the variables I remaned them and it does make it less confusing.

For the Loading procedure it was part of the project outline, we needed to show that the program was "loading" for a specific period of time. Really useless but its the project outline.
Tallguy




PostPosted: Thu Mar 27, 2008 8:05 am   Post subject: Re: Capitals of Canada Quiz

sup jess. you should really zip your folder so we can get the pics. and my program is better then urs Razz check it out in the submissions pge, called 'Capitols Quiz' Exclamation

Clayton wrote:

I'm surprised no one has noticed this yet, but what's with that big honking loading procedure? If I had to sit through that, I might have to off myself. Not only does it not take that long to load images, but it's entirely pointless. Don't make your user sit through something they don't have to.


we had to have a loading or a splash screen in out program (i'm in her class Wink ) it is pointless but always do what the teacher wants if you want to pass
Tony




PostPosted: Thu Mar 27, 2008 9:48 am   Post subject: Re: RE:Capitals of Canada Quiz

Jessica359 @ Thu Mar 27, 2008 7:41 am wrote:
For the Loading procedure it was part of the project outline...

Could somebody please forward a link to the above blog article on Loading Bar Anti-Pattern to that teacher?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mackie




PostPosted: Thu Mar 27, 2008 11:43 am   Post subject: RE:Capitals of Canada Quiz

That's sad what could the teacher be thinking? That's not teaching good habits, or anything for that matter.
Tony




PostPosted: Thu Mar 27, 2008 12:03 pm   Post subject: RE:Capitals of Canada Quiz

While at it, I hope you guys are not taught to use the Waterfall model
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: