Skip to content

Instantly share code, notes, and snippets.

@hchood
hchood / oop_i_4.rb
Created November 26, 2013 03:00
OOP Fundamentals I: Assignment 4
# OOP Fundamentals I: Assignment 4
class Card
def initialize(rank, suit)
@suit = suit
@rank = rank
end
def rank
@rank
@hchood
hchood / oop_i_5.rb
Created November 26, 2013 12:28
OOP Fundamentals I: Assignment 5
# OOP Fundamentals I: Assignment 5
class Whiteboard
attr_accessor :contents
def initialize(contents = [])
@contents = contents
end
def erase
@hchood
hchood / oop_i_6.rb
Last active December 29, 2015 10:29
OOP Fundamentals I: Assignment 6
# OOP Fundamentals I: Assignment 6
class DryEraseMarker
attr_reader :color, :capacity
def initialize(color)
@color = color
@capacity = 100
end
INK_USE_PER_CHARACTER = 0.01
@hchood
hchood / phase4.rb
Created November 27, 2013 16:14
phase 4. rb
# Implement your solution here. You may reference any additional files from here as well.
require 'pry'
winners = []
while true
puts "What was Team 1's name? "
team1 = gets.chomp
@hchood
hchood / grade_calculator.rb
Created November 29, 2013 17:14
OOP Fundamentals I: Teacher's Assistant Challenge
require 'csv'
require 'table_print'
require 'pry'
# require_relative 'grade_reader'
# require_relative 'student'
# require_relative 'assignment_grade'
# require_relative 'grade_summary'
# *************************************************************
# CLASSES
@hchood
hchood / test_scores.rb
Created November 29, 2013 23:49
OOP Fundamentals I: Non-core Test Scores Problem
require 'csv'
require 'pry'
class Student
attr_reader :name, :score
def initialize(name, score)
@name = name
@score = score
end
@hchood
hchood / circle.rb
Created November 29, 2013 23:55
OOP Fundamentals I: Non-core Circle Problem
class Circle
def initialize(radius)
@radius = radius
end
def diameter
@radius * 2
end
def circumference
@hchood
hchood / mortgage_calculator.rb
Created November 30, 2013 12:44
OOP Fundamentals I: Non-core Mortgage Calculator Problem
require 'csv'
# contents of home_info.csv:
# Address,Property Value,Selling Price,Down Payment
# 43 Fenmore Lane,439000,419000,20000
# 58 Johnson Way,512000,524000,105000
# 32 Silver Lane,485000,490000,97000
# 45 Fenway Drive,465000,460000,93000
# 54 Denise Drive,445000,450000,98000
@hchood
hchood / oo_blackjack.rb
Created December 1, 2013 17:59
OOP Fundamentals I: Non-core Blackjack Problem
#!/usr/bin/env ruby
# encoding: UTF-8
SUITS = ['♠', '♣', '♥', '♦']
VALUES = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
# ***********************************************************
# CLASSES
# ***********************************************************
@hchood
hchood / tax_man.rb
Created December 2, 2013 18:26
OOP Fundamentals I: Non-core Tax Man Problem
citizens = [
{
first_name: 'Johnny',
last_name: 'Smith',
annual_income: 120000,
tax_paid: 28000
},
{
first_name: 'Liz',