Skip to content

Instantly share code, notes, and snippets.

View vanmichael's full-sized avatar

van nguyen vanmichael

  • OpenTable
  • San Francisco
View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 6 columns, instead of 3 in line 1.
last_name,first_name,base_salary,percentage,bonus,limit
Smith,Johnny,80000
McMahon,Jimmy,85000
Lob,Bob,50000,0.5
Bobby,Ricky,40000,1.5
Krabappel,Edna,87000
Groundskeeper,Willie,75000,0,5000,60000
Wiggum,Clancy,80000,0,10000,80000
Burns,Charles,500000,0,1000,0
class Animal
def initialize(name)
@name = name
end
def emote
"#{@name} "
end
require 'pry'
class Circle
def initialize(radius)
@radius = radius
end
def diameter
2 * @radius
class Whiteboard
attr_accessor :contents
def initialize(contents = [])
@contents = contents
end
#instance method to erase whiteboard
def erase_whiteboard
@contents = []
@vanmichael
vanmichael / getters.rb
Created November 26, 2013 15:36
Example 2 for getters in Launch Academy
class Card
def initialize(rank, suit)
@suit = suit
@rank = rank
end
def rank
@rank
end
class television
def initialize(model, size, color)
@model = model
@size = size
@color = color
end
end
class channel(number,broadcaster)
def initialize(number,broadcaster)
@vanmichael
vanmichael / card_quick_challenge.rb
Created November 26, 2013 15:02
Card Quick Challenge for Launch Academy
class Card
def initialize(rank = nil, suit = nil)
if suit.nil?
@suit = ['♠', '♣', '♥', '♦'].sample
else
@suit = suit
end
if rank.nil?
@rank = ['2','3','4','5','6','7','8','9','10','J','Q','K'].sample
else
#By Van and Collin
require './register.rb'
require 'pry'
cashier = Register.new
cashier.load_products("products.csv")
while cashier.get_selection != 'done'
if cashier.menu_selection == '1'
while cashier.get_item != 'done' do
@vanmichael
vanmichael / change_machine.rb
Created November 25, 2013 12:56
Kata Change Machine
#The Change Machine
#by van
class Change
attr_reader :dollars, :quarters, :dimes, :pennies, :change
def initialize
get_amount_due
get_amount_tendered
@vanmichael
vanmichael / game_of_thrones.rb
Created November 25, 2013 02:48
Add your name to the Game of Thrones List!
require 'pry'
class House
attr_reader :character, :house, :selection
def initialize
@characters = {
"Tyrion Lannister" => "House Lannister",
"Jon Snow" => "Night's Watch",