View submit_application.rb
# A user submits their loan application
class SubmitApplication
def initialize(applicant, loan)
...
end
def execute
update_loan_workflow
charge_applicant_credit_card
check_applicant_fico_score
View submit_application.rb
# A user submits their loan application
class SubmitApplication
# store any state that you'll need to do your action
def initialize(applicant, loan)
@applicant = applicant
@loan = loan
end
end
View no_animations.rb
module Rack
# disable CSS3 and jQuery animations in test mode for speed, consistency and avoiding timing issues.
# Usage for Rails:
# in config/environments/test.rb
# config.middleware.use Rack::NoAnimations
class NoAnimations
def initialize(app, options = {})
@app = app
end
View valid_triangle.rb
def valid_triangle?(a, b, c)
if ((a == 0 or b == 0 or c == 0) or (a == nil or b == nil or c == nil))
return false
end
if a + b > c
puts "case 1"
return true
View leap_year.rb
def leap_year?(year)
if year % 4 == 0
puts "I am divisible by 4!"
true
elsif year % 100 == 0
puts "I am divisible by 100!"
false
elsif year % 100 == 0 && year % 400 == 0
puts "I am divisible by 100 and 400!"
true
View pairing.md

Exercise: The Restaurant Wait Time

We have been contracted to write a piece of software for a restaurant. They want to easily be able to enter orders that come in, and be told how long the wait time will be for that order. That is, we are going to write a simple program for placing an order at a restaurant and it will print to the screen how long the wait is.

You can order the following items:

  • pizza
  • spaghetti
  • lasagna
  • salad
View prep_pairing.md

Dev Bootcamp Prep Pairing

What is pairing?

Pairing is when two programmers work together on a problem. We do it a lot at DBC.

Since we'll be pairing with you, if you don't know something, like some fact or detail, that's fine. You should really focus on how to think and talk about the challenge (the technical problem), ie. how to explain what you're thinking, follow what we do together and talk about it, and be able to recognize when we've succeeded!

Most of all just try to relax and enjoy working with us through this process.

View check_out.rb
require_relative "rules"
# An object which represents the checkout process or cash register.
# It scans items, which are added to an internal list of items,
# which are then used to return the #total at any given moment.
# This total tries to use the rules which lead to the cheapest price.
class CheckOut < Struct.new(:rules)
attr_accessor :rules # list of available pricing rules (passed on initialization)
attr_accessor :items # hash of scanned items and quantities
# { "A" => 0, "B" => 1 } means we have scanned one "A" and zero "B"s
View user_bad.rb
require 'sqlite3'
require_relative 'user_db' # Setup user table
# Open a database
db = SQLite3::Database.new "test.db"
while true
# Get user input.
puts "Add user:"
user_name = gets.strip
View post_bad.rb
require 'sqlite3'
require_relative 'post_db' # Setup db table
# Open a database
db = SQLite3::Database.new "test.db"
while true
# Get book name
puts "Find post by name:"
post_name = gets.strip