Skip to content

Instantly share code, notes, and snippets.

@Nursultan91
Created April 14, 2019 16:45
Show Gist options
  • Save Nursultan91/28360d55523a7a26d79c083c8f72e7e3 to your computer and use it in GitHub Desktop.
Save Nursultan91/28360d55523a7a26d79c083c8f72e7e3 to your computer and use it in GitHub Desktop.
Выдвет ошибку
require_relative 'drink'
require_relative 'purchase'
coce = Drink.new("CocaCola", "CC", 1.50)
pepsi = Drink.new("PepsiCola", "PC", 2.00)
water = Drink.new("Water", "WA", 0.85)
def drink_busket
puts "Write list of your drinks as it show in Example"
puts "Example: CC PC WA CC"
drink_array = gets.chomp.split(" ")
drink_hash = drink_array.inject(Hash.new(0)) {|drink,count| drink[count] += 1; drink }
puts drink_hash
drink_hash.to_a.each {|drink, count| puts "#{drink}: #{count}"}
drink_hash.to_a.each do |drink, count|
i = Purchase.new(drink, count.to_i)
end
end
drink_busket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment