You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
520 B
31 lines
520 B
# By alan snape
|
|
# All rights reserved.
|
|
|
|
class Dessert
|
|
attr_accessor :name, :calories
|
|
def initialize(name, calories)
|
|
self.name = name
|
|
self.calories = calories
|
|
end
|
|
def healthy?
|
|
return self.calories < 200
|
|
end
|
|
def delicious?
|
|
return true
|
|
end
|
|
end
|
|
|
|
class JellyBean < Dessert
|
|
attr_accessor :flavor
|
|
def initialize(flavor)
|
|
self.flavor = flavor
|
|
self.calories = 5
|
|
end
|
|
def name
|
|
return self.flavor + ' jelly bean'
|
|
end
|
|
def delicious?
|
|
return 'licorice' != self.flavor
|
|
end
|
|
end
|