Skip to content

Instantly share code, notes, and snippets.

@sdanko11
Last active December 29, 2015 10:39
Show Gist options
  • Save sdanko11/7658928 to your computer and use it in GitHub Desktop.
Save sdanko11/7658928 to your computer and use it in GitHub Desktop.
class Whiteboard
attr_accessor :contents
def initialize(contents = [])
@contents = contents
end
def erase_contents(contents)
contents = 100
end
end
class DryEraseMarker
attr_reader :color, :capacity
def initialize(color)
@color = color
@capacity = 100
def ink_remaining
@capacity > 0
end
end
INK_USE_PER_CHARACTER = 0.01
def write(contents, whiteboard)
@capacity = @capacity - (INK_USE_PER_CHARACTER * contents.length)
whiteboard.contents << contents
end
end
whiteboard = Whiteboard.new
black_marker = DryEraseMarker.new('black')
black_marker.write('Hello Launchers', whiteboard)
black_marker.write('My name is Slim Shady', whiteboard)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment