Last active
January 1, 2016 23:19
-
-
Save brittanmcg/8215628 to your computer and use it in GitHub Desktop.
Shopping list app
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 List | |
def initialize | |
@items = [] | |
end | |
def add_item(*var) | |
@items << var | |
@items.flatten! | |
end | |
def delete_item(*var) | |
@items.delete(*var) #I'm having some issues here with deleting multiple items. | |
end | |
def favorite_item(*fav) | |
@favs = [] | |
@favs << fav | |
end | |
def print_favs | |
p @favs | |
end | |
def print_list | |
p @items | |
end | |
def add_store | |
end | |
end | |
Chaps_list = List.new | |
Chaps_list.add_item("bacon") | |
#p Chaps_list | |
Chaps_list.add_item("dog food", "tomatoes", "paper towels") | |
#p Chaps_list | |
Chaps_list.delete_item("paper towels") | |
#p Chaps_list | |
Chaps_list.favorite_item("coffee", "toilet paper") | |
Chaps_list.print_favs | |
Chaps_list.favorite_item("dog food", "bananas") #I'm not sure why this method is not holding these items in this array permanantly. | |
Chaps_list.print_favs | |
Chaps_list.print_list | |
# Your Driver Code goes here... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment