Introduction to Programming Logic/Lesson 2: Conditionals and Logic
From Wikiversity
conditionals and logic
ok since i am a rookie feel free to correct me
but lets take the robot idea
you have a set of commands for him
if you tell him anything else he does his "do the locomotion dance"
(this of course would be the else option)
say you have options 1-4
you say option 1
he follows you and has a light that fill the area right in front of you
you say option 2
he follows behind you and plays your theme song
(bright side of life from monty pithons life of brian)
you say option 3
he writes down everything you say into a file that can be uploaded to your computer using his usb port
you say option 4
he he turns goes to his power base and powers up
now these all have their issues but lets start when you say option 5 because he doesn't have anything programmed into this variable option (case) case 5 is not defined well this is like a definite loop it would cause an error so we use the else case
input user (voice recognition command+case_num) ( for (case_num);
( if case 1 then do lighting routine if case 2 then play <theme_song_user> if case 3 then run note taking program if case 4 then move home connect to power enter sleep mode else do <do the locomotion routine> )
) return 0;
___________________________________________________ now scrappy has a definite action to take for any "case" command given to him
assuming his "do the locomotion routine" has a do until condition
and scrappy has voice recognition where he has specific values recorded for those allowed