Created
July 29, 2013 22:44
-
-
Save vjdhama/6108555 to your computer and use it in GitHub Desktop.
Edx Class 169.1x HW 1-4
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
#!/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