diff --git a/README.md b/README.md index ace8eba..a60a302 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Worksheets ---------- - [Ruby Programming and Shoes](http://github.com/railsbridge/teachingkids/tree/master/md/Ruby_Programming_and_Shoes.md) +- [A little game (Which is correct?)](http://github.com/railsbridge/teachingkids/tree/master/md/a_little_game_which_is_correct.md) Report from the field @@ -21,5 +22,5 @@ Link to Sarah Allen's blog: Change log ---------- -May 31st, 2009: Added the link to Sarah Allen's field report. +May 31st, 2009: Added the link to Sarah Allen's field report and a little game (Which is correct?) May 16th, 2009: Uploaded the resource of first lesson. \ No newline at end of file diff --git a/img/which_is_correct_1-1.png b/img/which_is_correct_1-1.png new file mode 100644 index 0000000..37c993c Binary files /dev/null and b/img/which_is_correct_1-1.png differ diff --git a/img/which_is_correct_1-2.png b/img/which_is_correct_1-2.png new file mode 100644 index 0000000..5c4bdf8 Binary files /dev/null and b/img/which_is_correct_1-2.png differ diff --git a/img/which_is_correct_1-3.png b/img/which_is_correct_1-3.png new file mode 100644 index 0000000..7ccabee Binary files /dev/null and b/img/which_is_correct_1-3.png differ diff --git a/img/which_is_correct_1-4.png b/img/which_is_correct_1-4.png new file mode 100644 index 0000000..9f50012 Binary files /dev/null and b/img/which_is_correct_1-4.png differ diff --git a/md/a_little_game_which_is_correct.md b/md/a_little_game_which_is_correct.md new file mode 100644 index 0000000..b9135ce --- /dev/null +++ b/md/a_little_game_which_is_correct.md @@ -0,0 +1,127 @@ +A little game (Which is correct?) +================================= + +Which is correct? +----------------- +**which_is_correct_1-1.png** + +![which_is_correct_1-1.png](http://github.com/railsbridge/teachingkids/tree/master%2Fimg%2Fwhich_is_correct_1-1.png?raw=true) + + +A bed of clams +-------------- +**which_is_correct_1-2.png** + +![which_is_correct_1-2.png](http://github.com/railsbridge/teachingkids/tree/master%2Fimg%2Fwhich_is_correct_1-2.png?raw=true) + + +A coalition of cheetahs +----------------------- +**which_is_correct_1-3.png** + +![which_is_correct_1-3.png](http://github.com/railsbridge/teachingkids/tree/master%2Fimg%2Fwhich_is_correct_1-3.png?raw=true) + + +A gulp of swallows +------------------ +**which_is_correct_1-4.png** + +![which_is_correct_1-4.png](http://github.com/railsbridge/teachingkids/tree/master%2Fimg%2Fwhich_is_correct_1-4.png?raw=true) + + +Code (which_is_correct_1.rb) +---------------------------- + # which_is_correct_1.rb + class OurApp < Shoes + url '/', :index + + def index + clear + para "Which is correct?" + stack { + @correct = button "A bed of clams" + @wrong1 =button "A coalition of cheetahs" + @wrong2 =button "A gulp of swallows" + } + + @correct.click { + clear + para "Correct" + image "http://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Balloons-aj.svg/550px-Balloons-aj.svg.png" + button "Go Back" do + visit "/" + end + + } + @wrong1.click { + clear + para "Wrong!" + image "http://icanhascheezburger.files.wordpress.com/2007/05/cheez_doing_it_wrong.jpg" + button "Go Back" do + visit "/" + end + } + @wrong2.click { + clear + para "Wrong, your consolation prize is..." + image "http://farm2.static.flickr.com/1166/1230713908_083d7f6c53_o.jpg", + :width => 500 + button "Go Back" do + visit "/" + end + } + + end # this is the end of the index method, which lays out the "/" page + + end # this is the end of the subclass, which contains all the pages (well, one page) + + Shoes.app + + +Revised Code (which_is_correct_2.rb) +------------------------------------ + # which_is_correct_1.rb + class OurApp < Shoes + url '/', :index + + def index + clear + para "Which is correct?" + stack { + @correct = button "A bed of clams" + @wrong1 =button "A coalition of cheetahs" + @wrong2 =button "A gulp of swallows" + } + + @correct.click { + clear + para "Correct" + image "http://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Balloons-aj.svg/550px-Balloons-aj.svg.png" + button "Go Back" do + visit "/" + end + + } + @wrong1.click { + clear + para "Wrong!" + image "http://icanhascheezburger.files.wordpress.com/2007/05/cheez_doing_it_wrong.jpg" + button "Go Back" do + visit "/" + end + } + @wrong2.click { + clear + para "Wrong, your consolation prize is..." + image "http://farm2.static.flickr.com/1166/1230713908_083d7f6c53_o.jpg", + :width => 500 + button "Go Back" do + visit "/" + end + } + + end # this is the end of the index method, which lays out the "/" page + + end # this is the end of the subclass, which contains all the pages (well, one page) + + Shoes.app diff --git a/src/which_is_correct_1.rb b/src/which_is_correct_1.rb new file mode 100644 index 0000000..199324a --- /dev/null +++ b/src/which_is_correct_1.rb @@ -0,0 +1,45 @@ +# which_is_correct_1.rb +class OurApp < Shoes + url '/', :index + + def index + clear + para "Which is correct?" + stack { + @correct = button "A bed of clams" + @wrong1 =button "A coalition of cheetahs" + @wrong2 =button "A gulp of swallows" + } + + @correct.click { + clear + para "Correct" + image "http://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Balloons-aj.svg/550px-Balloons-aj.svg.png" + button "Go Back" do + visit "/" + end + + } + @wrong1.click { + clear + para "Wrong!" + image "http://icanhascheezburger.files.wordpress.com/2007/05/cheez_doing_it_wrong.jpg" + button "Go Back" do + visit "/" + end + } + @wrong2.click { + clear + para "Wrong, your consolation prize is..." + image "http://farm2.static.flickr.com/1166/1230713908_083d7f6c53_o.jpg", + :width => 500 + button "Go Back" do + visit "/" + end + } + + end # this is the end of the index method, which lays out the "/" page + +end # this is the end of the subclass, which contains all the pages (well, one page) + +Shoes.app \ No newline at end of file diff --git a/src/which_is_correct_2.rb b/src/which_is_correct_2.rb new file mode 100644 index 0000000..f3e25ec --- /dev/null +++ b/src/which_is_correct_2.rb @@ -0,0 +1,35 @@ +# which_is_correct_2.rb +class Game < Shoes + url '/', :index + url '/correct', :show_correct + url '/wrong', :show_wrong + + def index + clear + para "Which is correct?" + stack { + @correct = button "A bed of clams" do + visit "/correct" + end + + @wrong1 =button "A coalition of cheetahs" do + visit "/wrong" + end + + @wrong2 =button "A gulp of swallows" do + visit "/wrong" + end + } + end # this is the end of the index method, which lays out the "/" page + + def show_correct + para "Correct" + end # of the "correct" method, which lays out the "/correct" page + + def show_wrong + para "Sorry, try again." + end # of the "wrong" method, which lays out the "/wrong2" page + +end # this is the end of the "Game" subclass, which contains all pages + +Shoes.app