Last active
January 16, 2020 20:53
-
-
Save Naomi-Dennis/dc25bb4bb30f6928087414dd529c8c39 to your computer and use it in GitHub Desktop.
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
def items | |
[ShopItem.new(20, "Paper"), | |
ShopItem.new(50, "Ball"), | |
ShopItem.new(40, "Book"), | |
ShopItem.new(4, "Chips")] | |
end | |
def find_item(item_name) | |
items.select do | item | | |
item.name == item_name | |
end.first | |
end | |
item = "Ball" | |
searched_item = find_item(item) | |
if searched_item != nil | |
money = perform_transaction(money, searched_item) | |
else | |
puts "We don't sell that item" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment