Skip to content

Instantly share code, notes, and snippets.

View jmoon90's full-sized avatar

John Moon jmoon90

  • New York, NY
View GitHub Profile
require "pry"
##!/usr/bin/env ruby
## encoding: UTF-8
SUITS = ['♠', '♣', '♥', '♦']
VALUES = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
def build_deck
deck = []
@jmoon90
jmoon90 / card.rb
Last active December 29, 2015 11:09
# Quick Challenge
class Card
def initialize(rank = nil, suit = nil)
if suit.nil?
@suit = ['♠', '♣', '♥', '♦'].sample
else
@suit = suit
end
if rank.nil?
class Channel
attr_accessor :channel_number
def initialize(channel_number)
@channel_number = channel_number
end
def change_channel(channel_number)
puts "You are changing channels"
@channel_number = channel_number
end
class Car
def initialize(color, owner, cylinders)
@color = color
@owner = owner
@cylinders = cylinders
end
def color
@color
end
class Card
def initialize(rank, suit)
@suit = suit
@rank = rank
end
def rank
@rank
end
class Whiteboard
attr_accessor :contents
def initialize(contents = [])
@contents = contents
end
def dry_marker_eraser
@contents = []
end
@jmoon90
jmoon90 / final_grade.rb
Last active December 29, 2015 11:29
OOP 1 Challenges
class FinalGrade
attr_reader :student, :avg
def initialize(argument)
@avg = argument[:avg]
@student = argument[:student]
end
def letter_grade
return "A" if @avg >= 90
return "B" if @avg >= 80 && @avg < 90
# Implement your solution here. You may reference any additional files from here as well.
def phase_2
puts "What was team 1's name?"
team1 = gets.chomp
puts "What was team 1's score?"
t1score = gets.chomp.to_i
puts "What was team 2's name?"
team2 = gets.chomp
# Implement your solution here. You may reference any additional files from here as well.
TEAMS = (1..2).to_a
def questioner(question)
puts question + "?"
input = gets.chomp
end
def team_checker(name, hash)
hash.keys.include?(name)
@jmoon90
jmoon90 / circle.rb
Last active December 29, 2015 14:48
class Circle
def initialize(radius)
@radius = radius
@pi = 3.14159265359
end
def diameter
@radius * 2
end