Skip to content

Instantly share code, notes, and snippets.

View jackieiscool's full-sized avatar

Jacqueline Herrlin jackieiscool

View GitHub Profile
class Hero
def initialize(level)
@level = level
@health = @level * 100
end
def life
@health
end
@jackieiscool
jackieiscool / Book Class
Created June 18, 2012 19:46
Book Class
class Book
attr_reader :title
def title=(title)
@title = title.split
@title.each do |word|
a = ["the", "in", "a", "an", "and"]
if a.include?(word.downcase)
word.downcase!
else
@jackieiscool
jackieiscool / gist:2946534
Created June 18, 2012 02:40
Re-implement Array#count -- HELP
class Array
def new_count
final = 0
(1..self.length-1)each do |i|
final += 1 if yield(self[i])
end
return final
end
end
@jackieiscool
jackieiscool / Dictionary
Created June 16, 2012 01:05
Creating a dictionary class
class Dictionary
attr_reader :entries
def initialize()
@entries = {}
end
def add(words)
if words.class == String
@entries.merge!({words => nil})
else
@jackieiscool
jackieiscool / AHHHH!!!!!!!!
Created June 15, 2012 01:38
RECURSION!!!!!!!!!!!!!!!!!!!!
module InWords
def magic
ones_array = %w{ not_called one two three four five six seven eight nine ten}
tens_array = %w{ not_called not_called twenty thirty forty fifty sixty seventy eighty ninety}
teens_array = [ "" ] + %w{ one two three four five six seven eight nine ten eleven twelve
thirteen fourteen fifteen sixteen seventeen eighteen nineteen}
# if self == 0
# return "zero"
# end