Skip to content

Instantly share code, notes, and snippets.

@alacritythief
Created August 29, 2014 00:58
Show Gist options
  • Save alacritythief/0e945c7b17b7c9d2053f to your computer and use it in GitHub Desktop.
Save alacritythief/0e945c7b17b7c9d2053f to your computer and use it in GitHub Desktop.
Added .clean instance method to whiteboard to clear it.
class Whiteboard
attr_accessor :contents
def initialize(contents = [])
@contents = contents
end
def clean
@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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment