Last active
December 16, 2019 11:07
-
-
Save jjuliano/1c32b106f61f931be48da78db0a6f3ee 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 Basket | |
def initialize | |
@basket = [] | |
end | |
def add_item(kind, **item) | |
@basket << item.merge({kind: kind}) | |
puts "Entry #{item[:name]} created!" | |
puts | |
end | |
def print_items | |
puts "There are #{@basket.count} item(s) in the basket." | |
puts | |
@basket.each do |entry| | |
puts "Name: #{entry[:name]}" | |
puts "Flavour: #{entry[:flavour]}" | |
puts "Kind: #{entry[:kind]}" | |
puts | |
end | |
end | |
end | |
basket = Basket.new | |
basket.add_item( | |
"fruit", | |
name: "apple", | |
flavour: "It's a little sour and bitter, but mostly sweet, not at all salty, very juicy in general." | |
) | |
basket.print_items |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment