Bitmaker Labs – Day 7

Day 7 was a continuation of Day 6, which means we basically did more Test Driven Development all day. There wasn’t anything new really discussed today, Chris went over the CRM application we worked on during the weekend. He showed us an intro into how he would solve it, and the logic behind it. This confused some students, but also cleared things up for others. I already understood the concepts, so I felt good with the lecture.

After the lecture, we didn’t have any new assignments, so we started working on a bonus bowling assignment that was optional. I program paired with a friend here and we managed to solve it but in very ugly code. I then started redoing it again on my own with an instructor to help reinforce the concepts, but we got stuck. Soon afterwards it was 6pm, so he was off and I was left to figure it out. I progressed a bit more, before calling it a day and heading home.

The bowling assignment asks you to build an object that will take in an array, and calculate the final score. You have to know how to calculate strikes and pairs to figure out the final score, so it’s harder than it looks. You basically have to pass these tests:

require 'rspec'
describe Game do
 let (:game) { Game.new }
it "should score 300 for a game" do
 game.score(12.times.map { 10 }).should be == 300
 end
it "should score 0 for a gutter game" do
 game.score(12.times.map { 0 }).should be 0
 end
it "should score 20 for a game of all ones" do
 game.score(20.times.map { 1 }).should be == 20
 end
it "should score a 20 when a 5 is thrown after a spare" do
 game.score([5,5,5] + 17.times.map { 0 } ).should be == 20
 end
it "should score a 24 when a strike is followed by a 3 and 4" do
 game.score([10,3,4] + 17.times.map { 0 }).should be == 24
 end
it "should score 10 when a strike is followed by two gutter balls" do
 game.score([10] + 19.times.map { 0 }).should be == 10
 end
it "should score 20 when a gutter is followed by rolls of 10 and 5 pins" do
 game.score([0,10,5] + 17.times.map { 0 }).should be == 20
 end
it "should score 150 for rolls of all 5" do
 game.score(21.times.map { 5 }).should be == 150
 end
end

I need to figure out how to paste code and make it readable. There’s gotta be some sort of plugin for this.

Edit: Figured it out!

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*