Created
September 23, 2018 12:28
-
-
Save harrisonmalone/e7a53239e646a668db5f372f47d6ce33 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Hamburger | |
def initialize(patty, bun, condiments, cheese) | |
@patty = patty #string | |
@bun = bun #string | |
@condiments = condiments #array of strings | |
@cheese = cheese | |
@price = 450 | |
end | |
def get_cheese | |
return @cheese | |
end | |
def get_bun | |
return @bun | |
end | |
def get_condiments | |
return @condiments | |
end | |
def set_cheese(bool) | |
@cheese = bool | |
end | |
def set_conditments(condiment) | |
@condiments << condiment | |
end | |
end | |
hamburger1 = Hamburger.new('beef', 'brioche', ['tomato sauce'], true) | |
hamburger2 = Hamburger.new('chicken', 'sesame', ['onion relish', 'mayo'], true) | |
hamburger3 = Hamburger.new('veggie patty', 'turkish', ['mayonnaise'], true) | |
hamburger1.get_cheese | |
hamburger1.set_cheese(false) | |
condiments = [hamburger1.get_condiments, hamburger2.get_condiments, hamburger3.get_condiments] | |
hamburger1.set_conditments("bbq sauce") | |
# this is a simple class that implements a bunch of instance methods | |
# point of this example is to teach how a class works and why we need them |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment