Skip to content

Instantly share code, notes, and snippets.

@elcortez
Created April 18, 2019 09:54
Show Gist options
  • Save elcortez/57ffe3f3df55d5dc991e70f7ababb5d2 to your computer and use it in GitHub Desktop.
Save elcortez/57ffe3f3df55d5dc991e70f7ababb5d2 to your computer and use it in GitHub Desktop.
require_relative 'building'
require_relative 'butler'
class Castle < Building
attr_accessor :butler
def initialize(name, width, length, butler_name)
super(name, width, length)
@butler = Butler.new(butler_name, self)
end
def self.categories
['Medieval', 'Gothic', 'Renaissance']
end
def castle_details
"Castle #{name} has a butler named #{butler.name}"
end
def has_a_butler?
return @butler != nil
end
def floor_area
super + 300
end
end
castle = Castle.new('Le Château du Bonheur', 20, 20, 'Georges')
p castle.floor_area
p castle.butler
p castle.castle_details
p castle.butler.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment