Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add week5 and mid-term materials #5

Merged
merged 1 commit into from
Oct 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions midterm/instructions_and_questions.txt
Original file line number Diff line number Diff line change
@@ -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: [email protected]: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.


75 changes: 75 additions & 0 deletions midterm/mid_term_spec.rb
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions midterm/wish_list_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Binary file added week5/class_materials/week5.key
Binary file not shown.
Binary file added week5/class_materials/week5.pdf
Binary file not shown.
35 changes: 35 additions & 0 deletions week5/exercises/names
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions week5/homework/do_your_mid_term
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Work on your Mid-Term!!
Really Do your mid term!