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

Username:   Password: 
 RegisterRegister   
 Multiple If's
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Namis




PostPosted: Wed Sep 24, 2003 11:24 pm   Post subject: Multiple If's

Heres my code ;o

code:
put " Would you like some music while you answer my 20 questions? <Yes> or <No> "
if yes = "yes" or yes = "Yes" or yes = "YES" or yes = "YeS" or yes = "yES" or yes = "YEs" or yes = "yeS" or yes = "yEs"
        then
    put " Cool! Which band would you like to listen to? "
    delay (2000)
    put " <tool> or <malicemizer> or <aperfectcircle> "
    get music
    if music = "tool" or music = "Tool" or music = "TOOL" or music = "ToOl" or music = "TOol" or music = "tOOl" or music = "TOOl" or music = "ToOL"
            then
        put " Great Choice, Tool - Schism, will now play "
        delay (1000)
    %testing
Music.PlayFile ("C:\\Documents and Settings\Andrew\Desktop\Music\Tool\Lateralus.mp3")
end if


now for the other bands, ( and more songs after i figure out how this works ) do i keep it all under 1 if statement? or do i use multiple if statements? or do i j ust change the command line to

if music = "malicemizer" or
if music = "aperfectcircle" etc?
Something like this?
tool/malicemizer/aperfectcircle being different bands.
Sponsor
Sponsor
Sponsor
sponsor
Namis




PostPosted: Wed Sep 24, 2003 11:24 pm   Post subject: (No subject)

code:
put " Would you like some music while you answer my 20 questions? <Yes> or <No> "
if yes = "yes" or yes = "Yes" or yes = "YES" or yes = "YeS" or yes = "yES" or yes = "YEs" or yes = "yeS" or yes = "yEs"
        then
    put " Cool! Which band would you like to listen to? "
    delay (2000)
    put " <tool> or <malicemizer> or <aperfectcircle> "
    get music
    if music = "tool" or music = "Tool" or music = "TOOL" or music = "ToOl" or music = "TOol" or music = "tOOl" or music = "TOOl" or music = "ToOL"
           then
        put " Great Choice, Tool - Schism, will now play "
        delay (1000)
    %testing
Music.PlayFile ("C:\\Documents and Settings\Andrew\Desktop\Music\Tool\Lateralus.mp3")
end if
    if music = "malicemizer"
           then
        put " Great Choice, Malice Mizer - Baroque, will now play "
        delay (1000)
    %testing
Music.PlayFile ("C:\Documents and Settings\Andrew\Desktop\Music\Malice Mizer\CD4MEPLZ\Baroque.mp3")
end if
    if music = "aperfectcircle"
     then
        put " Great Choice, A Perfect Circle - Three Libras, will now play "
        delay (1000)
    %testing
Music.PlayFile ("C:\Documents and Settings\Andrew\Desktop\Music\A Perfect Circle\Three Libras.mp3")
end if
Tony




PostPosted: Wed Sep 24, 2003 11:29 pm   Post subject: (No subject)

come on, there's a tutorial on elsif's right here

I know you know its there because you even replied to that some time ago. Confused

Anyways, you need to make your program more organized. There're way to many ifs inside other ifs.

Also you should use a function that changes string to all caps (or all small) so that you dont write out two lines of possible input. Someone already wrote it, was probly even a re to one of your previous topics.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Namis




PostPosted: Wed Sep 24, 2003 11:30 pm   Post subject: (No subject)

Yeah im a retard, stab me in the face.

and if you think that is unorganized you should see the rest of my code, i get lost just looking at it Surprised
Tony




PostPosted: Wed Sep 24, 2003 11:33 pm   Post subject: (No subject)

Namis wrote:
Yeah im a retard, stab me in the face


*Tony stabs Namis in his face Twisted Evil *
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Amailer




PostPosted: Wed Sep 24, 2003 11:55 pm   Post subject: (No subject)

tony wrote:
Namis wrote:
Yeah im a retard, stab me in the face


*Tony stabs Namis in his face Twisted Evil *


how evil lol
Blade




PostPosted: Thu Sep 25, 2003 5:18 pm   Post subject: (No subject)

tony wrote:
Namis wrote:
Yeah im a retard, stab me in the face


*Tony stabs Namis in his face Twisted Evil *



ROCK ON MAN!!!! i wanted to stab him in the face but i didnt get here till later Sad
krishon




PostPosted: Thu Sep 25, 2003 5:55 pm   Post subject: (No subject)

even tho there are lots of ifs...some times...u hafta put some ifs inside others...especially in games. You must write the code for every single possiblilty (which is sometimes an ass)
PaddyLong




PostPosted: Thu Sep 25, 2003 10:04 pm   Post subject: (No subject)

man... you would be so better off writing some function to compare whether some variable is equal (case insensitive) to some word...

something like this...

code:

function wordsEqual (input, actualString : string) : boolean
    if length (input) not= length (actualString) then
        result false
    end if

    for i : 1 .. length (input)
        if ord (actualString (i)) >= 65 and ord (actualString (i)) <= 90 then
            if ord (input (i)) not= ord (actualString (i)) and
                    ord (input (i)) not= ord (actualString (i)) + 32 then
                result false
            end if
        elsif ord (actualString (i)) >= 97 and ord (actualString (i)) <= 122
                then
            if ord (input (i)) not= ord (actualString (i)) and
                    ord (input (i)) not= ord (actualString (i)) - 32 then
                result false
            end if
        else
            if ord (input (i)) not= ord (actualString (i)) then
                result false
            end if
        end if
    end for

    result true
end wordsEqual


then use it like this...

if wordsEqual (someInput, "yes") = true then
do whatever it is you do if they entered yes
end if
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  [ 9 Posts ]
Jump to:   


Style:  
Search: