Created
August 24, 2014 05:56
-
-
Save androide-osorio/00bdf89e15ca9b926c7f to your computer and use it in GitHub Desktop.
curso backend profesional mejorando.la: reto 2 ruby on rails
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
class Dessert | |
attr_accessor :name, :size, :calories | |
def initialize(name, size, calories) | |
@name = name | |
@size = size | |
@calories = calories | |
@@instance_count += 1 | |
end | |
def healthy? | |
@calories < 200 | |
end | |
def delicious? | |
true | |
end | |
def self.count | |
@@instance_count | |
end | |
end | |
class JellyBean < Dessert | |
attr_accessor :flavor | |
def initialize(name, size, calories, flavor) | |
super(name, size, calories) | |
@flavor = flavor | |
end | |
def delicious? | |
return false if @flavor == "black licorice" | |
super() | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment