Skip to content

Instantly share code, notes, and snippets.

@vjdhama
Created July 29, 2013 22:44
Show Gist options
  • Save vjdhama/6108555 to your computer and use it in GitHub Desktop.
Save vjdhama/6108555 to your computer and use it in GitHub Desktop.
Edx Class 169.1x HW 1-4
#!/usr/bin/env ruby
class Dessert
attr_accessor :name, :calories
def initialize(name, calories)
@name = name
@calories = calories
end
def healthy?
self.calories < 200
end
def delicious?
true
end
end
class JellyBean < Dessert
attr_accessor :flavor
def initialize(name, calories, flavor)
Dessert.initialize(name,calories)
@flavor = flavor
end
def delicious?
if flavor == 'black licorice'
return false
else
return true
end
end
end
d = JellyBean.new('teat',150,'choco')
puts d.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment