diff --git a/midterm/instructions_and_questions.txt b/midterm/instructions_and_questions.txt new file mode 100644 index 0000000..a038c9d --- /dev/null +++ b/midterm/instructions_and_questions.txt @@ -0,0 +1,39 @@ +Instructions for Mid-Term submission and Git Review (10pts): + - Create a git repository for your answers + - Add and Commit as you work through the questions and programming problems + - Your git log should reflect your work, don't just commit after you have finished working + - Use .gitignore to ignore any files that are not relevant to the midterm + - E-mail me your ssh public key + - I will email you back with your repository name + - Add a remote to your git repository: git@reneedv.com:RubyFall2014/YOURREPOSITORYNAME.git + - Push your changes to the remote + - After 6pm Thursday November 13th you will not be able to push to your remote repository (or clone). + + Questions (20pts): + - What are the three uses of the curly brackets {} in Ruby? + - What is a regular expression and what is a common use for them? + - What is the difference between how a String, a symbol, a FixNum, and a Float are stored in Ruby? + - Are these two statements equivalent? Why or Why Not? + 1. x, y = "hello", "hello" + 2. x = y = "hello" +- What is the difference between a Range and an Array? +- Why would I use a Hash instead of an Array? +- What is your favorite thing about Ruby so far? +- What is your least favorite thing about Ruby so far? + + Programming Problems (10pts each): + - Write a passing rspec file called even_number_spec.rb that tests a class called EvenNumber. + - The EvenNumber class should: + - Only allow even numbers + - Get the next even number + - Compare even numbers + - Generate a range of even numbers +- Make the rspec tests in wish_list_spec.rb pass by writing a WishList class + - The WishList class should: + - Mixin Enumerable + - Define each so it returns wishes as strings with their index as part of the string + +Mid-Term Spec (50pts): +- Make the tests pass. + + diff --git a/midterm/mid_term_spec.rb b/midterm/mid_term_spec.rb new file mode 100644 index 0000000..87e5c74 --- /dev/null +++ b/midterm/mid_term_spec.rb @@ -0,0 +1,75 @@ +require_relative '../../spec_helper.rb' +require "#{File.dirname(__FILE__)}/turkey" + +describe Turkey do + + before do + @turkey = Turkey.new(10) + end + + it "should report the turkey weight" do + @turkey.weight.should equal 10 + end + + it "should be a kind of animal" do + @turkey.kind_of?(Animal).should be_true + end + + it "should gobble speak" do + @turkey.gobble_speak("Hello I Am a Turkey. Please Don't Eat Me.").should eq "Gobble Gobble Gobble gobble Gobble. Gobble Gobb'le Gobble Gobble." + end + +end + +require "#{File.dirname(__FILE__)}/thanksgiving_dinner" + +describe ThanksgivingDinner do + + before do + @t_dinner = ThanksgivingDinner.new(:vegan) + @t_dinner.guests = ["Aunt Petunia", "Uncle Vernon", "Aunt Marge", "Dudley", "Harry"] # I know I just made a British family celebrate Thanksgiving, but it could be worse: It could have been the 4th of July! :) + end + + it "should be a kind of dinner" do + @t_dinner.kind_of?(Dinner).should be_true + end + + # Use inject here + it "should sum the letters in each guest name for the seating chart size" do + @t_dinner.seating_chart_size.should eq 45 + end + + it "should provide a menu" do + @t_dinner.respond_to?(:menu).should be_true + end + + context "#menu" do + + it "should have a diet specified" do + @t_dinner.menu[:diet].should eq :vegan + end + + it "should have proteins" do + @t_dinner.menu[:proteins].should eq ["Tofurkey", "Hummus"] + end + + it "should have vegetables" do + @t_dinner.menu[:veggies].should eq [:ginger_carrots , :potatoes, :yams] + end + + # Dinners don't always have dessert, but ThanksgivingDinners always do! + it "should have desserts" do + @t_dinner.menu[:desserts].should eq({:pies => [:pumkin_pie], :other => ["Chocolate Moose"], :molds => [:cranberry, :mango, :cherry]}) + end + + end + + # Use String interpolation, collection methods, and string methods for these two examples + it "should return what is on the dinner menu" do + @t_dinner.whats_for_dinner.should eq "Tonight we have proteins Tofurkey and Hummus, and veggies Ginger Carrots, Potatoes, and Yams." + end + + it "should return what is on the dessert menu" do + @t_dinner.whats_for_dessert.should eq "Tonight we have 5 delicious desserts: Pumkin Pie, Chocolate Moose, and 3 molds: Cranberry and Mango and Cherry." + end +end diff --git a/midterm/wish_list_spec.rb b/midterm/wish_list_spec.rb new file mode 100644 index 0000000..87f2813 --- /dev/null +++ b/midterm/wish_list_spec.rb @@ -0,0 +1,18 @@ +require "#{File.dirname(__FILE__)}/wish_list" + +describe WishList do + before :each do + @wish_list = WishList.new + @wish_list.wishes = ["Lamborghini", "Corn Starch and Water Moat", "Vegan Bacon Ice Cream", "Rubber Chicken", "Free Tickets to MockingJay"] + end + + it "should mixin Enumerable" do + @wish_list.is_a?(Enumerable).should be_true + end + + context "#each" do + it "should give me a numberd list" do + @wish_list.map{|w| w}.should eq ["1. Lamborghini", "2. Corn Starch and Water Moat", "3. Vegan Bacon Ice Cream", "4. Rubber Chicken", "5. Free Tickets to MockingJay"] + end + end +end \ No newline at end of file diff --git a/week5/class_materials/week5.key b/week5/class_materials/week5.key new file mode 100644 index 0000000..fd73408 Binary files /dev/null and b/week5/class_materials/week5.key differ diff --git a/week5/class_materials/week5.pdf b/week5/class_materials/week5.pdf new file mode 100644 index 0000000..a13a24a Binary files /dev/null and b/week5/class_materials/week5.pdf differ diff --git a/week5/exercises/names b/week5/exercises/names new file mode 100644 index 0000000..cb94f6f --- /dev/null +++ b/week5/exercises/names @@ -0,0 +1,35 @@ +Ben +BrianT +BrianWard +BryanWilliams +Cheri +ChrisB +ChristopherF +ChristopherT +Danny +Dimitry +Eddie +Emily +Gregory +Josh +Karen +Kat +Kelli +Kris +Mallory +Nell +NicholasP +Nicole +Nikky +Peter +Price +Renée +Ryan +Santy +Serene +Sol +Steven +Strand +Timothy +Will +Yan diff --git a/week5/homework/do_your_mid_term b/week5/homework/do_your_mid_term new file mode 100644 index 0000000..18c8d0e --- /dev/null +++ b/week5/homework/do_your_mid_term @@ -0,0 +1,2 @@ +Work on your Mid-Term!! +Really Do your mid term!