Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: joao9856 on November 08, 2012, 04:16:24 pm

Title: Need help with my code...
Post by: joao9856 on November 08, 2012, 04:16:24 pm
I've recently started to program and i tried making a guess my number game...
the code is very deorganized but it worked with easy dificulty, when i upgraded the game so it could have normal and hard nothing succeded.
adn i'm getting a litle frustrated :banghead: so i'll post the code to see if anyone could help me find my error.
don't mind the text they are in portuguese my mother tongue.
Code: [Select]
Define LibPub gan()=
Prgm
:Lbl z
:e:=0
:If e=e Then
:RequestStr "Facil=F Normal=N Dificil=D",a,0
:If a="F" Then
:Goto v
:ElseIf a="f" Then
:Goto v
:elseIf a="D" Then
:Goto l
:ElseIf a="d" Then
:Goto l
:elseIf a="N" Then
:Goto q
:ElseIf a="n" Then
:Goto q
:Lbl q
:b:=randInt(0,100)
:Lbl u
:Request "Adivinha o numero de 0-100",c,0
:If c=b Then
:Disp "Bom jogo acabaste em ",e," tentativas!"
:Lbl t
:RequestStr "Novo jogo? S\N?",d,0
:If d="S" Then
:e:=0
:Goto z
:ElseIf d="s" Then
:e:=0
:Goto z
:ElseIf d="N" Then
:Goto y
:ElseIf d="n" Then
:Goto y
:Else
:Goto t
:EndIf
:ElseIf c>b and c<101 Then
:Text "Muito alto!",0
:e:=e+1
:Goto u
:ElseIf c<b and c>−1 Then
:Text "Muito baixo!",0
:e:=e+1
:Goto u
:Else
:Text "É só de 0 a 100!"
:Goto u
:Lbl l
:b:=randInt(0,1000)
:Lbl m
:Request "Adivinha o numero de 0-1000",c,0
:If c=b Then
:Disp "Bom jogo acabaste em ",e," tentativas!"
:Lbl n
:RequestStr "Novo jogo? S\N?",d,0
:If d="S" Then
:e:=0
:Goto z
:ElseIf d="s" Then
:e:=0
:Goto z
:ElseIf d="N" Then
:Goto y
:ElseIf d="n" Then
:Goto y
:Else
:Goto n
:EndIf
:ElseIf c>b and c<1001 Then
:Text "Muito alto!",0
:e:=e+1
:Goto m
:ElseIf c<b and c>−1 Then
:Text "Muito baixo!",0
:e:=e+1
:Goto m
:Else
:Text "É só de 0 a 1000!"
:Goto m
:Lbl v
:b:=randInt(0,10)
:Lbl w
:Request "Adivinha o numero de 0-10",c,0
:If c=b Then
:Disp "Bom jogo acabaste em ",e," tentativas!"
:Lbl x
:RequestStr "Novo jogo? S\N?",d,0
:If d="S" Then
:e:=0
:Goto z
:ElseIf d="s" Then
:e:=0
:Goto z
:ElseIf d="N" Then
:Goto y
:ElseIf d="n" Then
:Goto y
:Else
:Goto x
:EndIf
:ElseIf c>b and c<11 Then
:Text "Muito alto!",0
:e:=e+1
:Goto w
:ElseIf c<b and c>−1 Then
:Text "Muito baixo!",0
:e:=e+1
:Goto w
:Else
:Text "É só de 0 a 10!"
:Goto w
:endif
:endif
:endif
:endif
:endif
:Lbl y
:EndPrgm
Title: Re: Need help with my code...
Post by: Rhombicuboctahedron on November 08, 2012, 10:08:33 pm
Hi, and welcome to omnimaga, and one question, are you Portuguese or Brazilian, or another?

I don’t know what you think went wrong.
It worked perfectly for me, so good job.
I’ll admit the code is pretty ugly, but it works, and my code is never pretty either.

One thing I’ll suggest though, is that you allow for N to work as one of your guesses to immediately exit the game, because it was annoying to have to keep playing because I couldn’t exit.
Title: Re: Need help with my code...
Post by: joao9856 on November 09, 2012, 03:08:42 am
I'm portuguese and i'll deal with that problem a litle later now i have to go to school.

EDIT: i came back already and for some reason the code was not running in my calc O.O, when i pasted it into my computer it worked in students software.
Added the option "exit" in the middle of the game like Rhombicuboctahedron suggested then i decided to try it in my calc with that little improvement to see if it worked since it didn't make any sense not to, and guess what it did work.

Now can anyone explain me why it was not working?
Title: Re: Need help with my code...
Post by: DJ Omnimaga on November 09, 2012, 09:09:06 pm
What OS version do you have? (Welcome to the forums by the way :D)
Title: Re: Need help with my code...
Post by: joao9856 on November 10, 2012, 01:37:50 pm
thanks.
I using os version 3.1.0.392 with Ndless installed latest version.
Title: Re: Need help with my code...
Post by: Rhombicuboctahedron on November 10, 2012, 02:14:26 pm
What OS is your student software in, and were you trying to send it from your computer to your calc, or was it already on your calc. It should work on your calc, actually, no matter even if your software OS is newer, so I have no idea why it wouldn’t have worked.
Title: Re: Need help with my code...
Post by: joao9856 on November 10, 2012, 07:17:27 pm
Students software is the latest, and i always work on the calc.No matter what it got fixed and the problem is not there to annoy me. And i couldn't use a letter as you suggested because the request asks for an integer so a string won't work, so i used a number that does not bother the game.