Skip to content

Instantly share code, notes, and snippets.

@alxjrvs
Created September 3, 2015 20:55
Show Gist options
  • Save alxjrvs/035787e1206eb9a1a075 to your computer and use it in GitHub Desktop.
Save alxjrvs/035787e1206eb9a1a075 to your computer and use it in GitHub Desktop.
class Table
attr_reader :legs
attr_accessor :color
def initialize(legs, material, color)
@legs = legs
@material = material
@color = color
end
def likes_table?(person)
color == person.favorite_color
end
# def color=(new_color)
# @color = new_color
# end
end
class Person
attr_reader :favorite_color
def initialize(favorite_color)
@favorite_color = favorite_color
end
end
round_table = Table.new(12, "Wood", "wood-colored")
pool_table = Table.new(4, "Felt", "green")
king_arthur = Person.new("blue")
round_table.likes_table? king_arthur
round_table.color = "blue"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment