Skip to content

Instantly share code, notes, and snippets.

View MarcelSF's full-sized avatar
🥨

Marcel Fonseca MarcelSF

🥨
  • Le Wagon
  • Rio de Janeiro
View GitHub Profile
require_relative 'helpers'
# TODO: you can build your christmas list program here!
# 1 -> Greet the user (simple puts)
puts "\n"
puts "*" * 31
puts "*" + " " * 29 + "*"
puts "* Welcome to Christmas List *"
puts "*" + " " * 29 + "*"
puts "*" * 31
# TODO: you can build your horse race program here!
# 1 -> Welcome the user
puts "Welcome to the Muenchen horse race!"
# while account_balance is greater than or equal to 10 && user_choice == 'y'
account_balance = 100
play_again = 'y'
while account_balance >= 10 && play_again == 'y'
horses = ["Joe the Brave", "Black Stalion", "Ronny the Rat", "Tony Macaroni"]
def calculate(number_one, number_two, operator)
if operator == "+"
number_one + number_two
elsif operator == "-"
number_one - number_two
elsif operator == "*"
number_one * number_two
elsif operator == "/"
number_one / number_two
else
@MarcelSF
MarcelSF / SETUP_DAY.md
Created April 14, 2021 09:11
Starting my coding journey...
@MarcelSF
MarcelSF / SETUP_DAY.md
Created January 22, 2021 10:09
Starting my coding journey...
def calculate(number_one, number_two, operator)
# if operator == '+'
# return number_one + number_two
# elsif operator == '-'
# return number_one - number_two
# elsif operator == '/'
# return number_one / number_two
# elsif operator == '*'
# return number_one * number_two
# else
@MarcelSF
MarcelSF / horse_race.rb
Created January 18, 2021 16:15
horse race solution
puts "Welcome to the Horse Race"
puts "How much money do you want to bet?"
balance = gets.chomp.to_i
answer = 'y'
while answer == 'y' && balance >= 10
@MarcelSF
MarcelSF / calculator_pseudo.rb
Created January 18, 2021 16:12
Calculator Pseudocode
# CALCULATOR:
# STEP 1:
# 1. Ask user for a number - puts
# 2. Save it in a variable - gets.chomp
# 3. Ask user for second number and save it in a variable
# 4. Show user options for operator and ask her to choose one, save it
# 5. Calculate what the user chose - if/elsif/else or case operator
# 6. Display the result to user -
# STEP2: MAKE IT LOOP
@MarcelSF
MarcelSF / pseudocode.rb
Created January 18, 2021 16:11
horse race pseudocode
# 1. Welcome the user
# 2. Define an array of horses
horses = [
"Seattle Slew",
"Secretariat",
"Seabiscuit",
"Citation"
]
# 3. Display horses (with each_with_index)
# 1. Joe the Brave
# TODO: you can build your instacart program here!
# 1. Greet the user
puts "Welcome to the Batch 531 fruit store!"
# 2. Model the store as a hash
store = {"kiwi" => 2, "apple" => 0.1, "strawberry" => 5, "banana" => 1}
# 3. Display what's available in the store, and iterate over the key/value pairs
store.each do |fruit, value|
puts "#{fruit} - price: $#{value}"
end
# 4. Initialize an empty shopping cart as an array.