Skip to content

Instantly share code, notes, and snippets.

@dmehrotra
Last active December 21, 2015 18:09
Show Gist options
  • Save dmehrotra/6345235 to your computer and use it in GitHub Desktop.
Save dmehrotra/6345235 to your computer and use it in GitHub Desktop.
erase
class Whiteboard
attr_accessor :contents
def initialize(contents = [])
@contents = contents
end
def erase
@contents = []
end
end
class DryEraseMarker
attr_reader :color, :capacity
def initialize(color)
@color = color
@capacity = 100
end
INK_USE_PER_CHARACTER = 0.01
def write(contents, whiteboard)
if ink_remaining?
@capacity = @capacity - (INK_USE_PER_CHARACTER * contents.length)
whiteboard.contents << contents
else
puts 'out of ink'
end
end
def ink_remaining?
if @capacity <= 0
return false
else
return true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment