This file contains hidden or 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
| # Mensagem de boas vindas | |
| puts "-" * 30 | |
| puts "Bem vindos a Pé de Pano store" | |
| puts "-" * 30 | |
| # Definir os produtos (nome, preço, stock) disponíveis | |
| products = { | |
| "kiwi" => { price: 1.25, stock: 5 }, | |
| "banana" => { price: 0.5, stock: 6 }, | |
| "manga" => { price: 4.0, stock: 3 }, |
This file contains hidden or 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
| # Mensagem de boas vindas | |
| puts "-" * 30 | |
| puts "Bem vindos a Pé de Pano store" | |
| puts "-" * 30 | |
| # Definir os produtos (nome, preço) disponíveis | |
| products = { | |
| "kiwi" => 1.25, | |
| "banana" => 0.5, | |
| "manga" => 4.0, |
This file contains hidden or 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
| # Mensagem de boas vindas | |
| puts "-" * 30 | |
| puts "Bem vindos a Pé de Pano store" | |
| puts "-" * 30 | |
| # Definir os produtos (nome, preço) disponíveis | |
| products = { | |
| "kiwi" => 1.25, | |
| "banana" => 0.5, | |
| "manga" => 4.0, |
This file contains hidden or 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
| # 1. Boas vindas a corrida de cavalos | |
| puts "Bem vindo a corrida de cavalos, quer apostar qual vai ganhar?" | |
| # 2. Definir os cavalos da competiçao | |
| horses = ["Malhado", "Pé de Pano", "Pangaré"] | |
| money = 100 # Dinheiro para a aposta | |
| loop do | |
| puts "Seu saldo é de #{money}." |
This file contains hidden or 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 calculator(number1, number2, operation) | |
| puts "number1: #{number1} number2: #{number2}" | |
| case operation | |
| when "+" | |
| number1 + number2 | |
| when "-" | |
| number1 - number2 | |
| when "*" | |
| number1 * number2 | |
| when "/" |
This file contains hidden or 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
| # 1. Mostrar uma mensagem de boas vindas | |
| puts "WELCOME TO DUMB CALCULATOR" | |
| puts "-"*30 | |
| # 2. Pedir o primeiro número e armazenar em uma variável | |
| puts "Enter the first number:" | |
| number1 = gets.chomp.to_i | |
| # 3. Pedir o segundo número e armazenar em uma variável | |
| puts "Enter the second number:" | |
| number2 = gets.chomp.to_i | |
| # 4. Perguntar qual a operação e armazenar |
This file contains hidden or 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 Animal | |
| attr_reader :name | |
| def initialize(name) | |
| @name = name | |
| end | |
| def self.phyla | |
| %w[Porifera Cnidaria Platyhelminthes Nematoda Annelida Arthropoda Mollusca Echinodermata Chordata] | |
| end |
This file contains hidden or 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 acronym(sentence) | |
| # separar as palavras da sentença | |
| words = sentence.split | |
| # pegar a primeira letra de cada palavra | |
| letters = [] | |
| words.each do |word| | |
| letters << word[0] | |
| end | |
| # juntas as letras, coloca em maiúscula e retorna | |
| letters.join.upcase |
This file contains hidden or 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
| require 'colored' # permite utilizar cores nas strings, como .red | |
| # mensagem de boas vindas | |
| puts ("-" * 30).yellow | |
| puts "Welcome to Instacart".yellow | |
| puts ("-" * 30).yellow | |
| store = { | |
| "kiwi" => {price: 1.25, stock: 5}, | |
| "banana" => {price: 0.5, stock: 4}, |
This file contains hidden or 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
| # mensagem de boas vindas | |
| puts "-" * 30 | |
| puts "Welcome to Instacart" | |
| puts "-" * 30 | |
| store = { | |
| "kiwi" => 1.25, | |
| "banana" => 0.5, | |
| "mango" => 4, | |
| "asparagus" => 9 |
NewerOlder