Created
August 29, 2014 01:03
-
-
Save alacritythief/b3c915378056ca830339 to your computer and use it in GitHub Desktop.
Added '.has_ink?' instance variable to check if the marker is empty or not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
def has_ink? | |
if @capacity !=0 | |
return true | |
else | |
return false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment