1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class Cart def initialize(items = []) @items = items end def add(product) @items.push(product) end def includes?(product) @items.include?(product) end def quantity_of(product) @items.find_all do |item| item == product end.count end end