Skip to content

Instantly share code, notes, and snippets.

@akcrono
Last active August 29, 2015 14:05
Show Gist options
  • Save akcrono/dba81146bd2649b3828e to your computer and use it in GitHub Desktop.
Save akcrono/dba81146bd2649b3828e to your computer and use it in GitHub Desktop.
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)
@capacity = @capacity - (INK_USE_PER_CHARACTER * contents.length)
whiteboard.contents << contents
end
def has_ink?
if capacity > 0
return true
end
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment