-
Star
(0)
You must be signed in to star a gist -
Fork
(217)
You must be signed in to fork a gist
-
-
Save davidvandusen/aa5fabf243fe3e7cb8f7 to your computer and use it in GitHub Desktop.
Revisions
-
David VanDusen revised this gist
May 5, 2015 . 1 changed file with 0 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,25 +0,0 @@ -
kvirani revised this gist
May 4, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ We'll use a method in our ruby file to simulate the interaction with this creatu ### How should these behaviors map to code? * Starting a conversation with the silly dog implies running the program via the command line * Having an endless conversation with Shakil implies a loop in the program * Speaking to Shakil implies reading a line of user input with the gets method * Shakil responding to you (usually by barking) implies the program printing a line using the puts method -
kvirani revised this gist
May 4, 2014 . No changes.There are no files selected for viewing
-
kvirani revised this gist
May 4, 2014 . 2 changed files with 28 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ Your cofounder has left for Hawaii and asked that you take care of his puppy for 2 weeks. As it turns out, this dog is a menace and won’t stop barking. His name is Shakil. He exhibits the following inexplicable behavior: If you say anything to him, he will just bark back once ("woof"), except: * If you pretend to be a dog and bark ("woof") at him, he will go a bit nuts and woof back at you three times, pretty loudly: "WOOF WOOF WOOF" * If you explicitly use his name and tell him to stop (either "shakil stop" or "Shakil STOP!") he will not respond back with a bark (enjoy your moment of peace) * If you pretend to be a cat and "meow" at him, he will go berserk and woof back at you five times: "woof woof woof woof woof" * If you say anything else but with the word "treat" thrown into the mix, he won’t bark back, thinking he’ll be getting a treat * If you say "go away" he manages to actually leave you alone by leaving the room. We'll use a method in our ruby file to simulate the interaction with this creature. ### How should these behaviors map to code? * Starting a conversation with the stupid dog implies running the program via the command line * Having an endless conversation with Shakil implies a loop in the program * Speaking to Shakil implies reading a line of user input with the gets method * Shakil responding to you (usually by barking) implies the program printing a line using the puts method * Leaving the room implies exiting the program ### As you are coding this, ask yourself: 1. Are you writing a single, gigantic method or breaking down your program into logical units? 2. Are you trying to write the entire logic for your app in one go? Instead consider writing the program in incremental steps by starting with the simplest runnable code, running it, adding slightly more code/logic, running it, and so on? This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,14 @@ # Save this file to your computer so you can run it # via the command line (Terminal) like so: # $ ruby shakil_the_dog.rb # # Your method should wait for user input, which corresponds # to you saying something to your dog (named Shakil). # You'll probably want to write other methods, but this # encapsulates the core dog logic def shakil_the_dog end # Run our method shakil_the_dog -
kvirani created this gist
Mar 4, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ # Save this file to your computer so you can run it # via the command line (Terminal) like so: # $ ruby stupid_dog.rb # # Your method should wait for user input, which corresponds # to you saying something to your dog (named Shakil). # You'll probably want to write other methods, but this # encapsulates the core dog logic def stupid_dog end # Run our method stupid_dog