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

Username:   Password: 
 RegisterRegister   
 Broken Calculator Game Problem PLEASE HELP!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
GobinG




PostPosted: Fri Jan 13, 2012 7:15 pm   Post subject: Broken Calculator Game Problem PLEASE HELP!

What is it you are trying to achieve?
http://www.mathsisfun.com/games/broken-calculator.html>


What is the problem you are having?
<First to get to the problem just press start, and go to LEVEL 2 as its the only one that works. So basically the equals button doesn't work. As well as the addition operation. Try multiplying 2 and 3, and the equal button doesn't work. BTW I am a beginner, and this is my culminating project worth 20 %>


Describe what you have tried to solve this problem
<Well I've tried everything and I can't seem to get it, so that's why I posted here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
<Answer Here>



Turing Project.zip
 Description:
So here's the file, sorry for the hassle with the zip, but I has images in it. It would be much appreciated if you can help me.

Download
 Filename:  Turing Project.zip
 Filesize:  21.69 KB
 Downloaded:  115 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Fri Jan 13, 2012 10:07 pm   Post subject: Re: Broken Calculator Game Problem PLEASE HELP!

GobinG wrote:
So basically the equals button doesn't work.

*looks through uncommented code to find which line handles mouse clicks on the equality button*
Turing:
elsif x > 750 and x < 820 and y > 140 and y < 70 then

Think carefully about what the conditions are. Will these conditions ever all be true at the same time?

GobinG wrote:
As well as the addition operation.

*more searching through uncommented code*
Turing:
elsif x > 660 and x < 730 and y > 70 and y < 140 then
    op := "+"
elsif x > 660 and x < 730 and y > 250 and y < 320 then
    op := "*"
    exit

Why does the multiplication button work and not the addition button? What is different in the code?

I realize I'm being overly critical of your comments (or lack thereof), but if you want someone to help you, adding a few comments help a lot. (It may even help you realize what's wrong on your own)
GobinG




PostPosted: Fri Jan 13, 2012 11:01 pm   Post subject: RE:Broken Calculator Game Problem PLEASE HELP!

Sorry about that. Thanks for commenting though. As for the equality button I found the mistake thanks to you, it was a careless mistake by me. The code was,

elsif x > 750 and x < 820 and y > 70 and y < 140

As for the addition button I still don't see a difference in the code.

BTW, thanks for hinting the answer instead of telling me, it helps.
Dreadnought




PostPosted: Sat Jan 14, 2012 1:56 pm   Post subject: Re: Broken Calculator Game Problem PLEASE HELP!

GobinG wrote:
As for the addition button I still don't see a difference in the code.


Turing:
elsif x > 660 and x < 730 and y > 70 and y < 140 then
    op := "+" % 1 line of code
elsif x > 660 and x < 730 and y > 250 and y < 320 then
    op := "*"
    exit % 2 lines of code
Raknarg




PostPosted: Sat Jan 14, 2012 3:02 pm   Post subject: RE:Broken Calculator Game Problem PLEASE HELP!

You just werent paying attention when you wrote the if statement. You said the upper boundary is 70 and the lower boundary is 140. Therefore, for the button to work, the mouse has to be above 140 and below 70 at teh same time.
mirhagk




PostPosted: Sat Jan 14, 2012 3:10 pm   Post subject: RE:Broken Calculator Game Problem PLEASE HELP!

@racknarg, um no it doesn't. It must be greater than 70 and less than 140.
Tony




PostPosted: Sat Jan 14, 2012 3:22 pm   Post subject: Re: Broken Calculator Game Problem PLEASE HELP!

used to be
Dreadnought @ Fri Jan 13, 2012 10:07 pm wrote:
*looks through uncommented code to find which line handles mouse clicks on the equality button*
Turing:
elsif x > 750 and x < 820 and y > 140 and y < 70 then

Think carefully about what the conditions are. Will these conditions ever all be true at the same time?

Though I guess that particular one had already been pointed out and fixed.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Sat Jan 14, 2012 3:31 pm   Post subject: RE:Broken Calculator Game Problem PLEASE HELP!

This is your culminating? I wish my culminating was this easy.
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Sat Jan 14, 2012 4:47 pm   Post subject: RE:Broken Calculator Game Problem PLEASE HELP!

Varies between teachers. I don't think there is any specific curriculum for compsci, because so far I've seen 5 grade ten compsci classes doing totally different things.
mirhagk




PostPosted: Sat Jan 14, 2012 4:57 pm   Post subject: RE:Broken Calculator Game Problem PLEASE HELP!

there is one. You must learn what variables and if statements are, that's about it lol. Oh other then the stupid stuff about the environment and jobs and crap.
Raknarg




PostPosted: Sat Jan 14, 2012 5:13 pm   Post subject: RE:Broken Calculator Game Problem PLEASE HELP!

oh yeah, we only did that part for two weeks, then we went on to turing for the rest of the semester. I actually learned a lot that whole year, I had a good teacher luckily
GobinG




PostPosted: Sat Jan 14, 2012 5:24 pm   Post subject: RE:Broken Calculator Game Problem PLEASE HELP!

Thanks for replying guys. As for the culminating, it was our choice of either making a game of our choice or some storybook. So I choose the game.

Thanks Dreadnought again, I fixed the problem. Just some more careless mistakes by me.

Now some how I have to figure out how to make the calculator do problems like 2 * 3 + 2. And how to make the AC Button function like it's supposed to be in a real calculator.
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 1  [ 12 Posts ]
Jump to:   


Style:  
Search: