Skip to content

Instantly share code, notes, and snippets.

@RobertoBarros
Created April 29, 2024 17:17
Show Gist options
  • Save RobertoBarros/0f66e7d9e6b71d5f2dc4c1b53cf90227 to your computer and use it in GitHub Desktop.
Save RobertoBarros/0f66e7d9e6b71d5f2dc4c1b53cf90227 to your computer and use it in GitHub Desktop.
batch_1680_reboot_instacart_part1
# Mensagem de boas vindas
puts "-" * 30
puts "Bem Vindos ao Mercado Tabajara"
puts "-" * 30
products= {
"kiwi" => 1.25,
"banana" => 0.50,
"mango" => 4,
"apple" => 3
}
# Mostrar todos os produtos com o preço
products.each do |product, price|
puts "Valor do #{product} é: #{price}"
end
puts "-" * 30
cart = []
# LOOP
loop do
# Perguntar qual produto quer adicionar
puts "Qual produto deseja adicionar: "
choice = gets.chomp.downcase
# Se colocar `quit` sai do loop
break if choice == "quit"
# Verificar se o produto existe e adicionar ao carrinho
if products.key?(choice)
cart << choice
else
puts "Produto inexistente"
end
# FIM DO LOOP
end
# Calcula o total da compra
total = 0
cart.each do |product|
price = products[product]
total += price
end
# Mostra o valor
puts "-" * 30
puts "Total = #{total}"
puts "-" * 30
@barbarajam
Copy link

Living in a remote area in Australia, my entertainment options are limited. Black Diamond Casino has been a wonderful find with its wide variety of games and robust security measures. Their customer service is always available, making me feel like I’m right at the casino floor. I suggest giving it a try if you enjoy gaming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment